#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*/ delay(int);
int gpio_get_value(int);
int /*<<< orphan*/ gpio_set_mode(int, char *);
int /*<<< orphan*/ gpio_set_value(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ shiftOut(int, int);
int send_command_SHT11(int command) {
  int ack;
  gpio_set_mode(38, "out");
  gpio_set_mode(40, "out");
  gpio_set_value(38, 1);
  gpio_set_value(40, 1);
  gpio_set_value(38, 0);
  gpio_set_value(40, 0);
  gpio_set_value(40, 1);
  gpio_set_value(38, 1);
  gpio_set_value(40, 0);
  shiftOut(1, command);
  gpio_set_value(40, 1);
  gpio_set_mode(38, "in");
  delay(20);
  ack = gpio_get_value(38);
  if (ack != 0) {
    perror("ACK Error 0");
  }
  gpio_set_value(40, 0);
  delay(320);
  ack = gpio_get_value(38);
  if (ack != 1) {
    perror("ACK Error 1");
    gpio_set_mode(38, "out");
    gpio_set_value(38, 1);
    gpio_set_mode(38, "in");
  }
  return 0;
}


x86 assembly (clang, -O0):
<send_command_SHT11>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x26,%edi
lea    0xe89(%rip),%rsi
call   1040 <gpio_set_mode@plt>
mov    $0x28,%edi
lea    0xe78(%rip),%rsi
call   1040 <gpio_set_mode@plt>
mov    $0x26,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x26,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x26,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    -0x4(%rbp),%esi
mov    $0x1,%edi
call   1080 <shiftOut@plt>
mov    $0x28,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x26,%edi
lea    0xdef(%rip),%rsi
call   1040 <gpio_set_mode@plt>
mov    $0x14,%edi
call   1050 <delay@plt>
mov    $0x26,%edi
call   1030 <gpio_get_value@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1247 <send_command_SHT11+0xe7>
lea    0xdc5(%rip),%rdi
call   1070 <perror@plt>
mov    $0x28,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    $0x140,%edi
call   1050 <delay@plt>
mov    $0x26,%edi
call   1030 <gpio_get_value@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     12b1 <send_command_SHT11+0x151>
lea    0xd98(%rip),%rdi
call   1070 <perror@plt>
mov    $0x26,%edi
lea    0xd74(%rip),%rsi
call   1040 <gpio_set_mode@plt>
mov    $0x26,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x26,%edi
lea    0xd58(%rip),%rsi
call   1040 <gpio_set_mode@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_command_SHT11>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xe94(%rip),%rbx
mov    $0x26,%edi
mov    %rbx,%rsi
call   1040 <gpio_set_mode@plt>
mov    $0x28,%edi
mov    %rbx,%rsi
call   1040 <gpio_set_mode@plt>
mov    $0x26,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x26,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x26,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
mov    $0x28,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    $0x1,%edi
mov    %ebp,%esi
call   1080 <shiftOut@plt>
mov    $0x28,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
lea    0xdfc(%rip),%rsi
mov    $0x26,%edi
call   1040 <gpio_set_mode@plt>
mov    $0x14,%edi
call   1050 <delay@plt>
mov    $0x26,%edi
call   1030 <gpio_get_value@plt>
test   %eax,%eax
jne    1258 <send_command_SHT11+0xf8>
mov    $0x28,%edi
xor    %esi,%esi
call   1060 <gpio_set_value@plt>
mov    $0x140,%edi
call   1050 <delay@plt>
mov    $0x26,%edi
call   1030 <gpio_get_value@plt>
cmp    $0x1,%eax
jne    1266 <send_command_SHT11+0x106>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xda8(%rip),%rdi
call   1070 <perror@plt>
jmp    122a <send_command_SHT11+0xca>
lea    0xda6(%rip),%rdi
call   1070 <perror@plt>
lea    0xd87(%rip),%rsi
mov    $0x26,%edi
call   1040 <gpio_set_mode@plt>
mov    $0x26,%edi
mov    $0x1,%esi
call   1060 <gpio_set_value@plt>
lea    0xd6b(%rip),%rsi
mov    $0x26,%edi
call   1040 <gpio_set_mode@plt>
jmp    124f <send_command_SHT11+0xef>

LLVM IR (-O0):
@.str = [4 x i8] c"out\00"
@.str.1 = [3 x i8] c"in\00"
@.str.2 = [12 x i8] c"ACK Error 0\00"
@.str.3 = [12 x i8] c"ACK Error 1\00"
define i32 @send_command_SHT11(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @gpio_set_mode(i32 40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gpio_set_value(i32 38, i32 1)
%7 = call i32 @gpio_set_value(i32 40, i32 1)
%8 = call i32 @gpio_set_value(i32 38, i32 0)
%9 = call i32 @gpio_set_value(i32 40, i32 0)
%10 = call i32 @gpio_set_value(i32 40, i32 1)
%11 = call i32 @gpio_set_value(i32 38, i32 1)
%12 = call i32 @gpio_set_value(i32 40, i32 0)
%13 = load i32, i32* %2
%14 = call i32 @shiftOut(i32 1, i32 %13)
%15 = call i32 @gpio_set_value(i32 40, i32 1)
%16 = call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @delay(i32 20)
%18 = call i32 @gpio_get_value(i32 38)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %1
%22 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %1
%24 = call i32 @gpio_set_value(i32 40, i32 0)
%25 = call i32 @delay(i32 320)
%26 = call i32 @gpio_get_value(i32 38)
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = icmp ne i32 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %23
%30 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%31 = call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @gpio_set_value(i32 38, i32 1)
%33 = call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %29, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"out\00"
@.str.1 = [3 x i8] c"in\00"
@.str.2 = [12 x i8] c"ACK Error 0\00"
@.str.3 = [12 x i8] c"ACK Error 1\00"
define i32 @send_command_SHT11(i32 %0) {
%2 = tail call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @gpio_set_mode(i32 40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @gpio_set_value(i32 38, i32 1)
%5 = tail call i32 @gpio_set_value(i32 40, i32 1)
%6 = tail call i32 @gpio_set_value(i32 38, i32 0)
%7 = tail call i32 @gpio_set_value(i32 40, i32 0)
%8 = tail call i32 @gpio_set_value(i32 40, i32 1)
%9 = tail call i32 @gpio_set_value(i32 38, i32 1)
%10 = tail call i32 @gpio_set_value(i32 40, i32 0)
%11 = tail call i32 @shiftOut(i32 1, i32 %0)
%12 = tail call i32 @gpio_set_value(i32 40, i32 1)
%13 = tail call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @delay(i32 20)
%15 = tail call i32 @gpio_get_value(i32 38)
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %1
%18 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %1
%20 = tail call i32 @gpio_set_value(i32 40, i32 0)
%21 = tail call i32 @delay(i32 320)
%22 = tail call i32 @gpio_get_value(i32 38)
%23 = icmp eq i32 %22, 1
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%26 = tail call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%27 = tail call i32 @gpio_set_value(i32 38, i32 1)
%28 = tail call i32 @gpio_set_mode(i32 38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %24, %19
ret i32 0
}