#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ gpio_clear(int);
int /*<<< orphan*/ gpio_set(int);
int /*<<< orphan*/ gpio_set_output(int);
scalar_t__ gpio_setup();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ usleep(int);
int lcd_reset(int reset_pin) {
  if (gpio_setup() != 0) {
    perror("Couldn't setup GPIO");
    exit(1);
  }
  gpio_set_output(reset_pin);
  int reset_pin_mask = 1 << reset_pin;
  int delay_between_commands = 200 * 1000;
  gpio_clear(reset_pin_mask);
  usleep(delay_between_commands);
  gpio_set(reset_pin_mask);
  usleep(delay_between_commands);
  return 0;
}


x86 assembly (clang, -O0):
<lcd_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1050 <gpio_setup@plt>
cmp    $0x0,%rax
je     11a2 <lcd_reset+0x32>
lea    0xe6d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
call   1040 <gpio_set_output@plt>
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
movl   $0x30d40,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <gpio_clear@plt>
mov    -0xc(%rbp),%edi
call   1090 <usleep@plt>
mov    -0x8(%rbp),%edi
call   1060 <gpio_set@plt>
mov    -0xc(%rbp),%edi
call   1090 <usleep@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_reset>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <gpio_setup@plt>
test   %rax,%rax
jne    11bc <lcd_reset+0x4c>
mov    %ebx,%edi
call   1040 <gpio_set_output@plt>
mov    $0x1,%ebp
mov    %ebx,%ecx
shl    %cl,%ebp
mov    %ebp,%edi
call   1030 <gpio_clear@plt>
mov    $0x30d40,%edi
call   1090 <usleep@plt>
mov    %ebp,%edi
call   1060 <gpio_set@plt>
mov    $0x30d40,%edi
call   1090 <usleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe3d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Couldn't setup GPIO\00"
define i32 @lcd_reset(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i64 (...) @gpio_setup()
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i32 @gpio_set_output(i32 %11)
%13 = load i32, i32* %2
%14 = shl i32 1, %13
store i32 %14, i32* %3
store i32 200000, i32* %4
%15 = load i32, i32* %3
%16 = call i32 @gpio_clear(i32 %15)
%17 = load i32, i32* %4
%18 = call i32 @usleep(i32 %17)
%19 = load i32, i32* %3
%20 = call i32 @gpio_set(i32 %19)
%21 = load i32, i32* %4
%22 = call i32 @usleep(i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Couldn't setup GPIO\00"
define i32 @lcd_reset(i32 %0) {
%2 = tail call i64 (...) @gpio_setup()
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call i32 @gpio_set_output(i32 %0)
%9 = shl nuw i32 1, %0
%10 = tail call i32 @gpio_clear(i32 %9)
%11 = tail call i32 @usleep(i32 200000)
%12 = tail call i32 @gpio_set(i32 %9)
%13 = tail call i32 @usleep(i32 200000)
ret i32 0
}