#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*/ closeJetduino();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ jet_sleep(int);
int openJetduino();
int /*<<< orphan*/ printf(char *, int);
int ultrasonicRead(int);
int main(void) {
  int dval;
  int i = 0;
  int pin = 4;
  if (openJetduino() == -1)
    exit(1);
  for (i = 0; i < 2000; i++) {
    dval = ultrasonicRead(pin);
    printf("Range: %d\n", dval);
    jet_sleep(100);
  }
  closeJetduino();
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x4,-0x10(%rbp)
mov    $0x0,%al
call   1040 <openJetduino@plt>
cmp    $0xffffffff,%eax
jne    1197 <main+0x37>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7d0,-0xc(%rbp)
jge    11dd <main+0x7d>
mov    -0x10(%rbp),%edi
call   1050 <ultrasonicRead@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    $0x64,%edi
call   1080 <jet_sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <main+0x3e>
mov    $0x0,%al
call   1060 <closeJetduino@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <openJetduino@plt>
cmp    $0xffffffff,%eax
je     11b6 <main+0x56>
mov    $0x7d0,%ebp
lea    0xe85(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x4,%edi
call   1050 <ultrasonicRead@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x64,%edi
call   1080 <jet_sleep@plt>
add    $0xffffffff,%ebp
jne    1180 <main+0x20>
xor    %eax,%eax
call   1060 <closeJetduino@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Range: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 4, i32* %4
%5 = call i32 (...) @openJetduino()
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
store i32 0, i32* %3
br label %10
10: ; preds = %19, %9
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 2000
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %4
%15 = call i32 @ultrasonicRead(i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 @jet_sleep(i32 100)
br label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %10
22: ; preds = %10
%23 = call i32 (...) @closeJetduino()
ret i32 1
}

LLVM IR (-O2):
@.str = [11 x i8] c"Range: %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @openJetduino()
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @exit(i32 1)
unreachable
5: ; preds = %0, %5
%6 = phi i32 [ %10, %5 ], [ 0, %0 ]
%7 = tail call i32 @ultrasonicRead(i32 4)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @jet_sleep(i32 100)
%10 = add nuw nsw i32 %6, 1
%11 = icmp eq i32 %10, 2000
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = tail call i32 (...) @closeJetduino()
ret i32 1
}