#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 analogRead(int);
int /*<<< orphan*/ closeJetduino();
int /*<<< orphan*/ exit(int);
int openJetduino();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usleep(int);
int main(void) {
  int adata;
  int i = 0;
  int pin = 54;
  if (openJetduino() == -1)
    exit(1);
  for (i = 0; i < 2000; i++) {
    adata = analogRead(54);
    printf("analog read %d\n", adata);
    if (adata == -1)
      printf("IO Error");
    usleep(10000);
  }
  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   $0x36,-0x10(%rbp)
mov    $0x0,%al
call   1040 <openJetduino@plt>
cmp    $0xffffffff,%eax
jne    1197 <main+0x37>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7d0,-0xc(%rbp)
jge    11f9 <main+0x99>
mov    $0x36,%edi
call   1070 <analogRead@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    11e1 <main+0x81>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x2710,%edi
call   1080 <usleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <main+0x3e>
mov    $0x0,%al
call   1050 <closeJetduino@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <openJetduino@plt>
cmp    $0xffffffff,%eax
je     11df <main+0x7f>
mov    $0x7d0,%ebx
lea    0xe81(%rip),%r15
lea    0xe8a(%rip),%r14
jmp    119f <main+0x3f>
nopl   0x0(%rax,%rax,1)
mov    $0x2710,%edi
call   1080 <usleep@plt>
add    $0xffffffff,%ebx
je     11c8 <main+0x68>
mov    $0x36,%edi
call   1070 <analogRead@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0xffffffff,%ebp
jne    1190 <main+0x30>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1190 <main+0x30>
xor    %eax,%eax
call   1050 <closeJetduino@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"analog read %d\0A\00"
@.str.1 = [9 x i8] c"IO Error\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 54, 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 = %23, %9
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 2000
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = call i32 @analogRead(i32 54)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %13
%22 = call i32 @usleep(i32 10000)
br label %23
23: ; preds = %21
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %10
26: ; preds = %10
%27 = call i32 (...) @closeJetduino()
ret i32 1
}

LLVM IR (-O2):
@.str = [16 x i8] c"analog read %d\0A\00"
@.str.1 = [9 x i8] c"IO Error\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, %12
%6 = phi i32 [ %14, %12 ], [ 0, %0 ]
%7 = tail call i32 @analogRead(i32 54)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %7, -1
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = tail call i32 @usleep(i32 10000)
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, 2000
br i1 %15, label %16, label %5
16: ; preds = %12
%17 = tail call i32 (...) @closeJetduino()
ret i32 1
}