#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int fread(char *, int, int, int /*<<< orphan*/);
int fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
main(int argc, char *argv[]) {
  int n, kopurua = 512;
  char buf[512];
  if (argc == 2) {
    kopurua = atoi(argv[1]);
    if ((kopurua < 1) || (kopurua > 512)) {
      perror("kopurua ez dago 1..512 tartean\n");
      exit(-1);
    };
    ;
  }
  while ((n = fread(buf, sizeof(char), kopurua, stdin)) > 0)
    if (fwrite(buf, sizeof(char), n, stdout) != n) {
      perror("fwrite");
      exit(-1);
    };
  ;
  if (n == -1) {
    perror("fread");
    exit(-1);
  };
  ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x200,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11bc <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jl     11a1 <main+0x51>
cmpl   $0x200,-0x18(%rbp)
jle    11b7 <main+0x67>
lea    0xe58(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
jmp    11bc <main+0x6c>
jmp    11c1 <main+0x71>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    0x2e16(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    122b <main+0xdb>
lea    -0x220(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    0x2ddd(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
cmp    -0x14(%rbp),%eax
je     1226 <main+0xd6>
lea    0xe09(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
jmp    11c1 <main+0x71>
cmpl   $0xffffffff,-0x14(%rbp)
jne    124b <main+0xfb>
lea    0xdeb(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    $0x200,%r14d
cmp    $0x2,%edi
jne    1186 <main+0x36>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
add    $0xfffffdff,%eax
cmp    $0xfffffdff,%eax
jbe    1206 <main+0xb6>
mov    0x2e5b(%rip),%r15
mov    %rsp,%rbx
mov    0x2e41(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
call   1030 <fread@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11e6 <main+0x96>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1070 <fwrite@plt>
cmp    %ebp,%eax
je     11a0 <main+0x50>
lea    0xe49(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
cmp    $0xffffffff,%ebp
je     11fd <main+0xad>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe23(%rip),%rdi
jmp    11d7 <main+0x87>
lea    0xdf3(%rip),%rdi
jmp    11d7 <main+0x87>

LLVM IR (-O0):
@.str = [32 x i8] c"kopurua ez dago 1..512 tartean\0A\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.1 = [7 x i8] c"fwrite\00"
@.str.2 = [6 x i8] c"fread\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [512 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 512, i32* %7
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %25
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %11
%19 = load i32, i32* %7
%20 = icmp sgt i32 %19, 512
br i1 %20, label %21, label %24
21: ; preds = %18, %11
%22 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %18
br label %25
25: ; preds = %24, %2
br label %26
26: ; preds = %42, %25
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%28 = load i32, i32* %7
%29 = load i32, i32* @stdin
%30 = call i32 @fread(i8* %27, i32 1, i32 %28, i32 %29)
store i32 %30, i32* %6
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %43
32: ; preds = %26
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%34 = load i32, i32* %6
%35 = load i32, i32* @stdout
%36 = call i32 @fwrite(i8* %33, i32 1, i32 %34, i32 %35)
%37 = load i32, i32* %6
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %32
br label %26
43: ; preds = %26
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 -1)
unreachable
49: ; preds = %43
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [32 x i8] c"kopurua ez dago 1..512 tartean\0A\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.1 = [7 x i8] c"fwrite\00"
@.str.2 = [6 x i8] c"fread\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = add i32 %9, -513
%11 = icmp ult i32 %10, -512
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %6, %2
%16 = phi i32 [ %9, %6 ], [ 512, %2 ]
br label %17
17: ; preds = %21, %15
%18 = load i32, i32* @stdin
%19 = call i32 @fread(i8* %4, i32 1, i32 %16, i32 %18)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite(i8* %4, i32 1, i32 %19, i32 %22)
%24 = icmp eq i32 %23, %19
br i1 %24, label %17, label %25
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %17
%29 = icmp eq i32 %19, -1
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %28
ret i32 0
}