#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*/ bzero(char *, int);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
void func2(int fd) {
  char pov[300];
  bzero(pov, 300);
  write(fd, "Time to test your exploit...\n", 29);
  write(fd, ">", 1);
  read(fd, pov, 460);
  write(fd, pov, 324);
}


x86 assembly (clang, -O0):
<func2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x130(%rbp),%rdi
mov    $0x12c,%esi
call   1050 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    0xea7(%rip),%rsi
mov    $0x1d,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    0xeb1(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0x1cc,%edx
call   1040 <read@plt>
mov    -0x4(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0x144,%edx
call   1030 <write@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func2>:
push   %r14
push   %rbx
sub    $0x138,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x12c,%esi
call   1050 <bzero@plt>
lea    0xead(%rip),%rsi
mov    %ebx,%edi
mov    $0x1d,%edx
call   1030 <write@plt>
lea    0xeb8(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1cc,%edx
call   1040 <read@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x144,%edx
call   1030 <write@plt>
add    $0x138,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Time to test your exploit...\0A\00"
@.str.1 = [2 x i8] c">\00"
define void @func2(i32 %0) {
%2 = alloca i32
%3 = alloca [300 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%5 = call i32 @bzero(i8* %4, i32 300)
%6 = load i32, i32* %2
%7 = call i32 @write(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 29)
%8 = load i32, i32* %2
%9 = call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%10 = load i32, i32* %2
%11 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%12 = call i32 @read(i32 %10, i8* %11, i32 460)
%13 = load i32, i32* %2
%14 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%15 = call i32 @write(i32 %13, i8* %14, i32 324)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Time to test your exploit...\0A\00"
@.str.1 = [2 x i8] c">\00"
define void @func2(i32 %0) {
%2 = alloca [300 x i8]
%3 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 0
%4 = call i32 @bzero(i8* %3, i32 300)
%5 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 29)
%6 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = call i32 @read(i32 %0, i8* %3, i32 460)
%8 = call i32 @write(i32 %0, i8* %3, i32 324)
ret void
}