#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*/ receivedata_action(int, int);
int /*<<< orphan*/ receivedata_close(int);
int receivedata_open();
int main(int argc, char *argv[]) {
  int fd;
  fd = receivedata_open();
  for (int i = 0; i < 10; i++) {
    receivedata_action(fd, 0);
  }
  receivedata_action(fd, 1);
  receivedata_close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <receivedata_open@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    1179 <main+0x49>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <main+0x27>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1050 <receivedata_action@plt>
mov    -0x14(%rbp),%edi
call   1040 <receivedata_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <receivedata_open@plt>
mov    %eax,%ebx
mov    %eax,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <receivedata_action@plt>
mov    %ebx,%edi
call   1040 <receivedata_close@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @receivedata_open()
store i32 %8, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %15, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32, i32* %6
%14 = call i32 @receivedata_action(i32 %13, i32 0)
br label %15
15: ; preds = %12
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 1
store i32 %17, i32* %7
br label %9
18: ; preds = %9
%19 = load i32, i32* %6
%20 = call i32 @receivedata_action(i32 %19, i32 1)
%21 = load i32, i32* %6
%22 = call i32 @receivedata_close(i32 %21)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @receivedata_open()
%4 = tail call i32 @receivedata_action(i32 %3, i32 0)
%5 = tail call i32 @receivedata_action(i32 %3, i32 0)
%6 = tail call i32 @receivedata_action(i32 %3, i32 0)
%7 = tail call i32 @receivedata_action(i32 %3, i32 0)
%8 = tail call i32 @receivedata_action(i32 %3, i32 0)
%9 = tail call i32 @receivedata_action(i32 %3, i32 0)
%10 = tail call i32 @receivedata_action(i32 %3, i32 0)
%11 = tail call i32 @receivedata_action(i32 %3, i32 0)
%12 = tail call i32 @receivedata_action(i32 %3, i32 0)
%13 = tail call i32 @receivedata_action(i32 %3, i32 0)
%14 = tail call i32 @receivedata_action(i32 %3, i32 1)
%15 = tail call i32 @receivedata_close(i32 %3)
ret i32 0
}