#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*/ printf(char *);
int read(int /*<<< orphan*/, char **, unsigned int);
int main(int argc, char **argv) {
  if (argc != 2) {
    return -1;
  }
  unsigned int count = argv[1][0];
  if (count > 9) {
    return 0;
  }
  char *buf[10];
  int sz = read(0, buf, count);
  if (sz > 0) {
    printf("WIN: Read more than zero data\n");
  }
  return sz;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     114f <main+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jbe    1173 <main+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <main+0x80>
lea    -0x70(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %edi,%edi
call   1040 <read@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jle    119a <main+0x7a>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
mov    $0xffffffff,%ebx
cmp    $0x2,%edi
jne    1159 <main+0x39>
mov    0x8(%rsi),%rax
movzbl (%rax),%edx
xor    %ebx,%ebx
cmp    $0x9,%edx
ja     1159 <main+0x39>
mov    %rsp,%rsi
xor    %edi,%edi
call   1040 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1159 <main+0x39>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"WIN: Read more than zero data\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10 x i8*]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %32
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp ugt i32 %19, 9
br i1 %20, label %21, label %22
21: ; preds = %12
store i32 0, i32* %3
br label %32
22: ; preds = %12
%23 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%24 = load i32, i32* %6
%25 = call i32 @read(i32 0, i8** %23, i32 %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = load i32, i32* %8
store i32 %31, i32* %3
br label %32
32: ; preds = %30, %21, %11
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@str = [30 x i8] c"WIN: Read more than zero data\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8*]
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = load i8, i8* %7
%9 = icmp ugt i8 %8, 9
br i1 %9, label %19, label %10
10: ; preds = %5
%11 = zext i8 %8 to i32
%12 = bitcast [10 x i8*]* %3 to i8*
%13 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 0
%14 = call i32 @read(i32 0, i8** %13, i32 %11)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %16, %10
br label %19
19: ; preds = %18, %5, %2
%20 = phi i32 [ -1, %2 ], [ %14, %18 ], [ 0, %5 ]
ret i32 %20
}