#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*/ gui_start(int *, int *);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int infd, outfd;
  gui_start(&infd, &outfd);
  char buf[1024];
  int r;
  while ((r = read(infd, buf, 1024)) > 0)
    write(outfd, buf, r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <gui_start@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1040 <read@plt>
mov    %eax,-0x424(%rbp)
cmp    $0x0,%eax
jle    1193 <main+0x63>
mov    -0x18(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x424(%rbp),%edx
call   1030 <write@plt>
jmp    1156 <main+0x26>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <gui_start@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x400,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    1193 <main+0x63>
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1040 <read@plt>
test   %eax,%eax
jg     1170 <main+0x40>
xor    %eax,%eax
add    $0x410,%rsp
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
%8 = alloca [1024 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @gui_start(i32* %6, i32* %7)
br label %11
11: ; preds = %16, %2
%12 = load i32, i32* %6
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%14 = call i32 @read(i32 %12, i8* %13, i32 1024)
store i32 %14, i32* %9
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* %7
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%19 = load i32, i32* %9
%20 = call i32 @write(i32 %17, i8* %18, i32 %19)
br label %11
21: ; preds = %11
ret i32 0
}

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