#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*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int pin_read(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ read(int, char *, int);
int main() {
  int gp3_27 = pin_read("91");
  int gp6_31 = pin_read("191");
  int gp1_24 = pin_read("24");
  int gp7_8 = pin_read("200");
  int count = 0;
  char c1, c2, c3, c4;
  for (int i = 0; i < 10000000 / 2; ++i) {
    read(gp3_27, &c1, 1);
    read(gp6_31, &c2, 1);
    read(gp1_24, &c3, 1);
    read(gp7_8, &c4, 1);
    if (c1 == '1') {
      ++count;
    }
    if (c2 == '1') {
      ++count;
    }
    if (c3 == '1') {
      ++count;
    }
    if (c4 == '1') {
      ++count;
    }
    lseek(gp3_27, 0, SEEK_SET);
    lseek(gp6_31, 0, SEEK_SET);
    lseek(gp1_24, 0, SEEK_SET);
    lseek(gp7_8, 0, SEEK_SET);
  }
  printf("count is %d\n", count);
  close(gp3_27);
  close(gp6_31);
  close(gp1_24);
  close(gp7_8);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9b(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,-0x8(%rbp)
lea    0xe8b(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,-0xc(%rbp)
lea    0xe80(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,-0x10(%rbp)
lea    0xe74(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x4c4b40,-0x20(%rbp)
jge    12ac <main+0x15c>
mov    -0x8(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    -0xc(%rbp),%edi
lea    -0x1a(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    -0x10(%rbp),%edi
lea    -0x1b(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    -0x14(%rbp),%edi
lea    -0x1c(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x31,%eax
jne    1210 <main+0xc0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movsbl -0x1a(%rbp),%eax
cmp    $0x31,%eax
jne    1226 <main+0xd6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movsbl -0x1b(%rbp),%eax
cmp    $0x31,%eax
jne    123c <main+0xec>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movsbl -0x1c(%rbp),%eax
cmp    $0x31,%eax
jne    1252 <main+0x102>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d84(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0xc(%rbp),%edi
mov    0x2d71(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x10(%rbp),%edi
mov    0x2d5e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x14(%rbp),%edi
mov    0x2d4b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <main+0x59>
mov    -0x18(%rbp),%esi
lea    0xd55(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9c(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,0x14(%rsp)
lea    0xe8b(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,0x10(%rsp)
lea    0xe7f(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,0xc(%rsp)
lea    0xe72(%rip),%rdi
call   1070 <pin_read@plt>
mov    %eax,0x8(%rsp)
xor    %r12d,%r12d
mov    $0x4c4b40,%r13d
mov    0x14(%rsp),%r15d
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    %ebx,%edi
lea    0x6(%rsp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    %ebp,%edi
lea    0x5(%rsp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    0x8(%rsp),%edi
lea    0x4(%rsp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
xor    %eax,%eax
cmpb   $0x31,0x7(%rsp)
sete   %al
add    %r12d,%eax
xor    %ecx,%ecx
cmpb   $0x31,0x6(%rsp)
sete   %cl
add    %eax,%ecx
xor    %eax,%eax
cmpb   $0x31,0x5(%rsp)
sete   %al
add    %ecx,%eax
xor    %r12d,%r12d
cmpb   $0x31,0x4(%rsp)
sete   %r12b
add    %eax,%r12d
mov    0x2d9e(%rip),%r14
mov    (%r14),%edx
mov    %r15d,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    (%r14),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    (%r14),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    (%r14),%edx
mov    0x8(%rsp),%edi
xor    %esi,%esi
call   1040 <lseek@plt>
add    $0xffffffff,%r13d
jne    11c0 <main+0x70>
lea    0xd85(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
mov    0x14(%rsp),%edi
call   1050 <close@plt>
mov    0x10(%rsp),%edi
call   1050 <close@plt>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
mov    0x8(%rsp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"91\00"
@.str.1 = [4 x i8] c"191\00"
@.str.2 = [3 x i8] c"24\00"
@.str.3 = [4 x i8] c"200\00"
@SEEK_SET = global i32 0
@.str.4 = [13 x i8] c"count is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 @pin_read(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %2
%13 = call i32 @pin_read(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %13, i32* %3
%14 = call i32 @pin_read(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %14, i32* %4
%15 = call i32 @pin_read(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 %15, i32* %5
store i32 0, i32* %6
store i32 0, i32* %11
br label %16
16: ; preds = %68, %0
%17 = load i32, i32* %11
%18 = icmp slt i32 %17, 5000000
br i1 %18, label %19, label %71
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 @read(i32 %20, i8* %7, i32 1)
%22 = load i32, i32* %3
%23 = call i32 @read(i32 %22, i8* %8, i32 1)
%24 = load i32, i32* %4
%25 = call i32 @read(i32 %24, i8* %9, i32 1)
%26 = load i32, i32* %5
%27 = call i32 @read(i32 %26, i8* %10, i32 1)
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 49
br i1 %30, label %31, label %34
31: ; preds = %19
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %31, %19
%35 = load i8, i8* %8
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 49
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %41
41: ; preds = %38, %34
%42 = load i8, i8* %9
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 49
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %48
48: ; preds = %45, %41
%49 = load i8, i8* %10
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 49
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %55
55: ; preds = %52, %48
%56 = load i32, i32* %2
%57 = load i32, i32* @SEEK_SET
%58 = call i32 @lseek(i32 %56, i32 0, i32 %57)
%59 = load i32, i32* %3
%60 = load i32, i32* @SEEK_SET
%61 = call i32 @lseek(i32 %59, i32 0, i32 %60)
%62 = load i32, i32* %4
%63 = load i32, i32* @SEEK_SET
%64 = call i32 @lseek(i32 %62, i32 0, i32 %63)
%65 = load i32, i32* %5
%66 = load i32, i32* @SEEK_SET
%67 = call i32 @lseek(i32 %65, i32 0, i32 %66)
br label %68
68: ; preds = %55
%69 = load i32, i32* %11
%70 = add nsw i32 %69, 1
store i32 %70, i32* %11
br label %16
71: ; preds = %16
%72 = load i32, i32* %6
%73 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %72)
%74 = load i32, i32* %2
%75 = call i32 @close(i32 %74)
%76 = load i32, i32* %3
%77 = call i32 @close(i32 %76)
%78 = load i32, i32* %4
%79 = call i32 @close(i32 %78)
%80 = load i32, i32* %5
%81 = call i32 @close(i32 %80)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"91\00"
@.str.1 = [4 x i8] c"191\00"
@.str.2 = [3 x i8] c"24\00"
@.str.3 = [4 x i8] c"200\00"
@SEEK_SET = global i32 0
@.str.4 = [13 x i8] c"count is %d\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = tail call i32 @pin_read(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @pin_read(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @pin_read(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @pin_read(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %15
9: ; preds = %15
%10 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%11 = tail call i32 @close(i32 %5)
%12 = tail call i32 @close(i32 %6)
%13 = tail call i32 @close(i32 %7)
%14 = tail call i32 @close(i32 %8)
ret i32 0
15: ; preds = %0, %15
%16 = phi i32 [ 0, %0 ], [ %46, %15 ]
%17 = phi i32 [ 0, %0 ], [ %37, %15 ]
%18 = call i32 @read(i32 %5, i8* %1, i32 1)
%19 = call i32 @read(i32 %6, i8* %2, i32 1)
%20 = call i32 @read(i32 %7, i8* %3, i32 1)
%21 = call i32 @read(i32 %8, i8* %4, i32 1)
%22 = load i8, i8* %1
%23 = icmp eq i8 %22, 49
%24 = zext i1 %23 to i32
%25 = add nsw i32 %17, %24
%26 = load i8, i8* %2
%27 = icmp eq i8 %26, 49
%28 = zext i1 %27 to i32
%29 = add nsw i32 %25, %28
%30 = load i8, i8* %3
%31 = icmp eq i8 %30, 49
%32 = zext i1 %31 to i32
%33 = add nsw i32 %29, %32
%34 = load i8, i8* %4
%35 = icmp eq i8 %34, 49
%36 = zext i1 %35 to i32
%37 = add nsw i32 %33, %36
%38 = load i32, i32* @SEEK_SET
%39 = tail call i32 @lseek(i32 %5, i32 0, i32 %38)
%40 = load i32, i32* @SEEK_SET
%41 = tail call i32 @lseek(i32 %6, i32 0, i32 %40)
%42 = load i32, i32* @SEEK_SET
%43 = tail call i32 @lseek(i32 %7, i32 0, i32 %42)
%44 = load i32, i32* @SEEK_SET
%45 = tail call i32 @lseek(i32 %8, i32 0, i32 %44)
%46 = add nuw nsw i32 %16, 1
%47 = icmp eq i32 %46, 5000000
br i1 %47, label %9, label %15
}