#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ gpioInitialise();
int gpioRead(int);
main() {
  int i;
  int j;
  if (gpioInitialise() < 0)
    return 1;
  i = 5;
  FILE *f1 = fopen("client.data", "wb");
  int total;
  total = 0;
  while (total < 5000000) {
    j = gpioRead(i);
    total += 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <gpioInitialise@plt>
cmp    $0x0,%rax
jge    115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11a7 <main+0x77>
movl   $0x5,-0x8(%rbp)
lea    0xe96(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4c4b40,-0x1c(%rbp)
jge    11a7 <main+0x77>
mov    -0x8(%rbp),%edi
call   1050 <gpioRead@plt>
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <main+0x51>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <gpioInitialise@plt>
test   %rax,%rax
js     1173 <main+0x43>
lea    0xebc(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1040 <fopen@plt>
mov    $0x4c4b40,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x5,%edi
call   1050 <gpioRead@plt>
add    $0xffffffff,%ebx
jne    1160 <main+0x30>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"client.data\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 (...) @gpioInitialise()
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %19
9: ; preds = %0
store i32 5, i32* %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %4
store i32 0, i32* %5
br label %11
11: ; preds = %14, %9
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 5000000
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 @gpioRead(i32 %15)
store i32 %16, i32* %3
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %11
19: ; preds = %8, %11
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [12 x i8] c"client.data\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = tail call i64 (...) @gpioInitialise()
%2 = icmp slt i64 %1, 0
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %3, %5
%6 = phi i32 [ 0, %3 ], [ %8, %5 ]
%7 = tail call i32 @gpioRead(i32 5)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 5000000
br i1 %9, label %10, label %5
10: ; preds = %5, %0
%11 = phi i32 [ 1, %0 ], [ 0, %5 ]
ret i32 %11
}