#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*/ pi_2_mmio_input(int);
int /*<<< orphan*/ pi_2_mmio_set_high(int);
int /*<<< orphan*/ pi_2_mmio_set_input(int);
int /*<<< orphan*/ pi_2_mmio_set_low(int);
int /*<<< orphan*/ pi_2_mmio_set_output(int);
int /*<<< orphan*/ printf(char *);
void power_on_dht11() {
  pi_2_mmio_set_output(23);
  pi_2_mmio_set_high(23);
  pi_2_mmio_set_input(24);
  volatile int t = 0;
  while (!pi_2_mmio_input(24)) {
    t++;
    if (t > 200)
      break;
  }
  if (t > 200) {
    printf("DHT11 was not detected!! \nMake sure the sensor is connected and "
           "there is a 4.7k pullup between +ve and signal pins.\n");
    pi_2_mmio_set_low(23);
    exit(-1);
  }
  return;
}


x86 assembly (clang, -O0):
<power_on_dht11>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x17,%edi
call   1060 <pi_2_mmio_set_output@plt>
mov    $0x17,%edi
call   1050 <pi_2_mmio_set_high@plt>
mov    $0x18,%edi
call   1040 <pi_2_mmio_set_input@plt>
movl   $0x0,-0x4(%rbp)
mov    $0x18,%edi
call   1030 <pi_2_mmio_input@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11bc <power_on_dht11+0x4c>
jmp    11dd <power_on_dht11+0x6d>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    $0xc8,%eax
jle    11d8 <power_on_dht11+0x68>
jmp    11dd <power_on_dht11+0x6d>
jmp    119d <power_on_dht11+0x2d>
mov    -0x4(%rbp),%eax
cmp    $0xc8,%eax
jle    120b <power_on_dht11+0x9b>
lea    0xe0e(%rip),%rdi
call   1070 <printf@plt>
mov    $0x17,%edi
call   1080 <pi_2_mmio_set_low@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<power_on_dht11>:
push   %rax
mov    $0x17,%edi
call   1070 <pi_2_mmio_set_output@plt>
mov    $0x17,%edi
call   1060 <pi_2_mmio_set_high@plt>
mov    $0x18,%edi
call   1040 <pi_2_mmio_set_input@plt>
movl   $0x0,0x4(%rsp)
nopw   0x0(%rax,%rax,1)
mov    $0x18,%edi
call   1030 <pi_2_mmio_input@plt>
test   %eax,%eax
jne    11be <power_on_dht11+0x4e>
addl   $0x1,0x4(%rsp)
mov    0x4(%rsp),%eax
cmp    $0xc9,%eax
jl     11a0 <power_on_dht11+0x30>
mov    0x4(%rsp),%eax
cmp    $0xc9,%eax
jge    11cb <power_on_dht11+0x5b>
pop    %rax
ret
lea    0xe2e(%rip),%rdi
call   1050 <puts@plt>
mov    $0x17,%edi
call   1080 <pi_2_mmio_set_low@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [117 x i8] c"DHT11 was not detected!! \0AMake sure the sensor is connected and there is a 4.7k pullup between +ve and signal pins.\0A\00"
define void @power_on_dht11() {
%1 = alloca i32
%2 = call i32 @pi_2_mmio_set_output(i32 23)
%3 = call i32 @pi_2_mmio_set_high(i32 23)
%4 = call i32 @pi_2_mmio_set_input(i32 24)
store volatile i32 0, i32* %1
br label %5
5: ; preds = %15, %0
%6 = call i32 @pi_2_mmio_input(i32 24)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = load volatile i32, i32* %1
%11 = add nsw i32 %10, 1
store volatile i32 %11, i32* %1
%12 = load volatile i32, i32* %1
%13 = icmp sgt i32 %12, 200
br i1 %13, label %14, label %15
14: ; preds = %9
br label %16
15: ; preds = %9
br label %5
16: ; preds = %14, %5
%17 = load volatile i32, i32* %1
%18 = icmp sgt i32 %17, 200
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @pi_2_mmio_set_low(i32 23)
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %16
ret void
}

LLVM IR (-O2):
@str = [116 x i8] c"DHT11 was not detected!! \0AMake sure the sensor is connected and there is a 4.7k pullup between +ve and signal pins.\00"
define void @power_on_dht11() {
%1 = alloca i32
%2 = tail call i32 @pi_2_mmio_set_output(i32 23)
%3 = tail call i32 @pi_2_mmio_set_high(i32 23)
%4 = tail call i32 @pi_2_mmio_set_input(i32 24)
%5 = bitcast i32* %1 to i8*
store volatile i32 0, i32* %1
br label %6
6: ; preds = %9, %0
%7 = tail call i32 @pi_2_mmio_input(i32 24)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load volatile i32, i32* %1
%11 = add nsw i32 %10, 1
store volatile i32 %11, i32* %1
%12 = load volatile i32, i32* %1
%13 = icmp sgt i32 %12, 200
br i1 %13, label %14, label %6
14: ; preds = %9, %6
%15 = load volatile i32, i32* %1
%16 = icmp sgt i32 %15, 200
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([116 x i8], [116 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @pi_2_mmio_set_low(i32 23)
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %14
ret void
}