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

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
char *get_program_name(char *, int);
char *get_program_path(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char buf[1024];
  bzero(buf, sizeof(buf));
  printf("%s\n", get_program_path(buf, sizeof(buf)));
  bzero(buf, sizeof(buf));
  printf("%s\n", get_program_name(buf, sizeof(buf)));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
call   1040 <bzero@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
call   1060 <get_program_path@plt>
mov    %rax,%rsi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
call   1040 <bzero@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
call   1050 <get_program_name@plt>
mov    %rax,%rsi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <bzero@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <get_program_path@plt>
lea    0xe92(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <bzero@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <get_program_name@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @bzero(i8* %2, i32 1024)
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = call i8* @get_program_path(i8* %4, i32 1024)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%8 = call i32 @bzero(i8* %7, i32 1024)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%10 = call i8* @get_program_name(i8* %9, i32 1024)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @bzero(i8* %2, i32 1024)
%4 = call i8* @get_program_path(i8* %2, i32 1024)
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @bzero(i8* %2, i32 1024)
%7 = call i8* @get_program_name(i8* %2, i32 1024)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
ret i32 0
}