#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*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char const *);
int main(int argc, char **argv) {
  char *home = "/home/yohji/.geix";
  const char *path = "/portage.data";
  char dest[100] = {0};
  strcat(dest, home);
  strcat(dest, path);
  printf("%s\n", dest);
  char *buffer = malloc(sizeof(char));
  char *output = malloc(sizeof(char));
  FILE *stream = popen("cat /tmp/nohup.out", "r");
  if (stream != NULL) {
    while (fgets(buffer, sizeof(buffer), stream))
      strcat(output, buffer);
  }
  printf("%s", output);
  free(buffer);
  free(output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe77(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x90(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x90(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0x98(%rbp)
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0xa0(%rbp)
lea    0xe16(%rip),%rdi
lea    0xe22(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     1273 <main+0x103>
jmp    1234 <main+0xc4>
mov    -0x98(%rbp),%rdi
mov    -0xa8(%rbp),%rdx
mov    $0x8,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     126e <main+0xfe>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1090 <strcat@plt>
jmp    1234 <main+0xc4>
jmp    1273 <main+0x103>
mov    -0xa0(%rbp),%rsi
lea    0xdb8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x98(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe68(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe42(%rip),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <popen@plt>
test   %rax,%rax
je     1222 <main+0xc2>
mov    %rax,%r15
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1222 <main+0xc2>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
jmp    1200 <main+0xa0>
lea    0xe10(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"/home/yohji/.geix\00"
@.str.1 = [14 x i8] c"/portage.data\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [19 x i8] c"cat /tmp/nohup.out\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [100 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %7
%12 = bitcast [100 x i8]* %8 to i8*
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = call i32 @strcat(i8* %13, i8* %14)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%17 = load i8*, i8** %7
%18 = call i32 @strcat(i8* %16, i8* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i8* @malloc(i32 1)
store i8* %21, i8** %9
%22 = call i8* @malloc(i32 1)
store i8* %22, i8** %10
%23 = call i32* @popen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %23, i32** %11
%24 = load i32*, i32** %11
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %37
26: ; preds = %2
br label %27
27: ; preds = %32, %26
%28 = load i8*, i8** %9
%29 = load i32*, i32** %11
%30 = call i64 @fgets(i8* %28, i32 8, i32* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i8*, i8** %10
%34 = load i8*, i8** %9
%35 = call i32 @strcat(i8* %33, i8* %34)
br label %27
36: ; preds = %27
br label %37
37: ; preds = %36, %2
%38 = load i8*, i8** %10
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %9
%41 = call i32 @free(i8* %40)
%42 = load i8*, i8** %10
%43 = call i32 @free(i8* %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"/home/yohji/.geix\00"
@.str.1 = [14 x i8] c"/portage.data\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [19 x i8] c"cat /tmp/nohup.out\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%8 = call dereferenceable_or_null(1) i8* @malloc(i32 1)
%9 = call dereferenceable_or_null(1) i8* @malloc(i32 1)
%10 = call i32* @popen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = call i64 @fgets(i8* %8, i32 8, i32* %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12, %15
%16 = call i32 @strcat(i8* %9, i8* %8)
%17 = call i64 @fgets(i8* %8, i32 8, i32* %10)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %15
19: ; preds = %15, %12, %2
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%21 = call i32 @free(i8* %8)
%22 = call i32 @free(i8* %9)
ret i32 0
}