#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*/ O_RDONLY;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
char *getcwd(char *, int);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int sigaction(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void test5(int argc, char **argv) {
  puts("test5: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  int ret;
  char buff[512];
  char *c;
  ret = open("./main", O_RDONLY, 0);
  fputs("test1: sigaction: ret %d\n", stdout);
  ret = sigaction(SIGUSR1, 0, 0);
  fputs("test1: sigaction: ret %d\n", stdout);
  ret = sigprocmask(SIG_BLOCK, 0, 0);
  fputs("test1: sigprocmask: ret %d\n", stdout);
  c = getcwd(buff, 512);
  fputs("test1: getcwd: c %p buff %p '%s'\n", stdout);
  fputs("test1: brk: ret %d\n", stdout);
}


x86 assembly (clang, -O0):
<test5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe87(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
lea    0xe9c(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
lea    0xe89(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <sigaction@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
lea    0xe5f(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <sigprocmask@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
lea    0xe4f(%rip),%rdi
call   1060 <fputs@plt>
lea    -0x220(%rbp),%rdi
mov    $0x200,%esi
call   1070 <getcwd@plt>
mov    %rax,-0x228(%rbp)
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%esi
lea    0xe4b(%rip),%rdi
call   1060 <fputs@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test5>:
push   %r14
push   %rbx
sub    $0x208,%rsp
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0xea4(%rip),%rdi
xor    %edx,%edx
call   1080 <open@plt>
mov    0x2e34(%rip),%rbx
mov    (%rbx),%esi
lea    0xe94(%rip),%r14
mov    %r14,%rdi
call   1060 <fputs@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
call   1060 <fputs@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    (%rbx),%esi
lea    0xe6f(%rip),%rdi
call   1060 <fputs@plt>
mov    %rsp,%rdi
mov    $0x200,%esi
call   1070 <getcwd@plt>
mov    (%rbx),%esi
lea    0xe70(%rip),%rdi
call   1060 <fputs@plt>
mov    (%rbx),%esi
lea    0xe84(%rip),%rdi
call   1060 <fputs@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [42 x i8] c"test5: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00"
@.str.1 = [7 x i8] c"./main\00"
@O_RDONLY = global i32 0
@.str.2 = [26 x i8] c"test1: sigaction: ret %d\0A\00"
@stdout = global i32 0
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
@.str.3 = [28 x i8] c"test1: sigprocmask: ret %d\0A\00"
@.str.4 = [34 x i8] c"test1: getcwd: c %p buff %p '%s'\0A\00"
@.str.5 = [20 x i8] c"test1: brk: ret %d\0A\00"
define void @test5(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [512 x i8]
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = call i32 @puts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 0)
store i32 %10, i32* %5
%11 = load i32, i32* @stdout
%12 = call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @SIGUSR1
%14 = call i32 @sigaction(i32 %13, i32 0, i32 0)
store i32 %14, i32* %5
%15 = load i32, i32* @stdout
%16 = call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @SIG_BLOCK
%18 = call i32 @sigprocmask(i32 %17, i32 0, i32 0)
store i32 %18, i32* %5
%19 = load i32, i32* @stdout
%20 = call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%22 = call i8* @getcwd(i8* %21, i32 512)
store i8* %22, i8** %7
%23 = load i32, i32* @stdout
%24 = call i32 @fputs(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @stdout
%26 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"test5: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00"
@.str.1 = [7 x i8] c"./main\00"
@O_RDONLY = global i32 0
@.str.2 = [26 x i8] c"test1: sigaction: ret %d\0A\00"
@stdout = global i32 0
@SIGUSR1 = global i32 0
@SIG_BLOCK = global i32 0
@.str.3 = [28 x i8] c"test1: sigprocmask: ret %d\0A\00"
@.str.4 = [34 x i8] c"test1: getcwd: c %p buff %p '%s'\0A\00"
@.str.5 = [20 x i8] c"test1: brk: ret %d\0A\00"
define void @test5(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 0)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @SIGUSR1
%11 = tail call i32 @sigaction(i32 %10, i32 0, i32 0)
%12 = load i32, i32* @stdout
%13 = tail call i32 @fputs(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @SIG_BLOCK
%15 = tail call i32 @sigprocmask(i32 %14, i32 0, i32 0)
%16 = load i32, i32* @stdout
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = call i8* @getcwd(i8* %5, i32 512)
%19 = load i32, i32* @stdout
%20 = call i32 @fputs(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @stdout
%22 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %21)
ret void
}