#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*/ ssize_t;

/* Variables and functions */
int EXIT_SUCCESS;
int STDIN_FILENO;
int /*<<< orphan*/ arrayToUpper(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printArray(char *, int /*<<< orphan*/);
int /*<<< orphan*/ read(int, char *, int);
int main(int argc, char *argv[]) {
  int fd_in = STDIN_FILENO;
  ssize_t num_read;
  char buf[1024];
  while ((num_read = read(fd_in, buf, 1024)) > 0) {
    arrayToUpper(buf, num_read);
    printArray(buf, num_read);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1030 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    1198 <main+0x68>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <arrayToUpper@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <printArray@plt>
jmp    1155 <main+0x25>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    0x2e96(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0x400,%edx
call   1030 <read@plt>
test   %eax,%eax
jle    118a <main+0x5a>
mov    %eax,%ebp
mov    %rsp,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <arrayToUpper@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <printArray@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1030 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     1160 <main+0x30>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @STDIN_FILENO
store i32 %9, i32* %6
br label %10
10: ; preds = %15, %2
%11 = load i32, i32* %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 1024)
store i32 %13, i32* %7
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %10
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%17 = load i32, i32* %7
%18 = call i32 @arrayToUpper(i8* %16, i32 %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = load i32, i32* %7
%21 = call i32 @printArray(i8* %19, i32 %20)
br label %10
22: ; preds = %10
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = load i32, i32* @STDIN_FILENO
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 @read(i32 %4, i8* %5, i32 1024)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2, %8
%9 = phi i32 [ %12, %8 ], [ %6, %2 ]
%10 = call i32 @arrayToUpper(i8* %5, i32 %9)
%11 = call i32 @printArray(i8* %5, i32 %9)
%12 = call i32 @read(i32 %4, i8* %5, i32 1024)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %8, label %14
14: ; preds = %8, %2
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}