#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*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, char *,
                          int /*<<< orphan*/ *);
scalar_t__ fork();
char *getenv(char *);
char *malloc(int);
int /*<<< orphan*/ pipe(int *);
int readln(int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int temBackup(char *digest) {
  char buf[256], *home = getenv("HOME"), *data_dir;
  int fd[2], ret;
  data_dir = malloc((strlen(home) + 15) * sizeof(char));
  strcpy(data_dir, home);
  strcat(data_dir, "/.backup/data/");
  strcat(digest, ".gz");
  pipe(fd);
  if (fork() == 0) {
    close(fd[0]);
    dup2(fd[1], 1);
    close(2);
    execlp("find", "find", data_dir, "-name", digest, NULL);
  }
  close(fd[1]);
  wait(NULL);
  ret = readln(fd[0], buf);
  close(fd[0]);
  return ret;
}


x86 assembly (clang, -O0):
<temBackup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe2a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1050 <strlen@plt>
add    $0xf,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x118(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x120(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x128(%rbp),%rdi
call   1080 <pipe@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
cmp    $0x0,%rax
jne    12a3 <temBackup+0xe3>
mov    -0x128(%rbp),%edi
call   1070 <close@plt>
mov    -0x124(%rbp),%edi
mov    $0x1,%esi
call   1060 <dup2@plt>
mov    $0x2,%edi
call   1070 <close@plt>
mov    -0x120(%rbp),%rdx
mov    -0x8(%rbp),%r8
lea    0xd89(%rip),%rsi
lea    0xd87(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r9d
mov    %rsi,%rdi
call   10c0 <execlp@plt>
mov    -0x124(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <wait@plt>
mov    -0x128(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   10a0 <readln@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x128(%rbp),%edi
call   1070 <close@plt>
mov    -0x12c(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<temBackup>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %rdi,%r14
lea    0xe2a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    0xf(%rax),%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe02(%rip),%rsi
mov    %r15,%rdi
call   10b0 <strcat@plt>
lea    0xe02(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcat@plt>
lea    0x8(%rsp),%rdi
call   1080 <pipe@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
jne    1270 <temBackup+0xb0>
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
call   1060 <dup2@plt>
mov    $0x2,%edi
call   1070 <close@plt>
lea    0xdc0(%rip),%rdi
lea    0xdbe(%rip),%rcx
mov    %rdi,%rsi
mov    %r15,%rdx
mov    %r14,%r8
xor    %r9d,%r9d
call   10c0 <execlp@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
call   10a0 <readln@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    %ebx,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [15 x i8] c"/.backup/data/\00"
@.str.2 = [4 x i8] c".gz\00"
@.str.3 = [5 x i8] c"find\00"
@.str.4 = [6 x i8] c"-name\00"
define i32 @temBackup(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [2 x i32]
%7 = alloca i32
store i8* %0, i8** %2
%8 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, 15
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i8* @malloc(i32 %14)
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = load i8*, i8** %4
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %5
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%21 = load i8*, i8** %2
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%24 = call i32 @pipe(i32* %23)
%25 = call i64 (...) @fork()
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %1
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%29 = load i32, i32* %28
%30 = call i32 @close(i32 %29)
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%32 = load i32, i32* %31
%33 = call i32 @dup2(i32 %32, i32 1)
%34 = call i32 @close(i32 2)
%35 = load i8*, i8** %5
%36 = load i8*, i8** %2
%37 = call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %36, i32* null)
br label %38
38: ; preds = %27, %1
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 @close(i32 %40)
%42 = call i32 @wait(i32* null)
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%44 = load i32, i32* %43
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%46 = call i32 @readln(i32 %44, i8* %45)
store i32 %46, i32* %7
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%48 = load i32, i32* %47
%49 = call i32 @close(i32 %48)
%50 = load i32, i32* %7
ret i32 %50
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [15 x i8] c"/.backup/data/\00"
@.str.2 = [4 x i8] c".gz\00"
@.str.3 = [5 x i8] c"find\00"
@.str.4 = [6 x i8] c"-name\00"
define i32 @temBackup(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [2 x i32]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = bitcast [2 x i32]* %3 to i8*
%7 = tail call i32 @strlen(i8* %5)
%8 = add nsw i32 %7, 15
%9 = tail call i8* @malloc(i32 %8)
%10 = tail call i32 @strcpy(i8* %9, i8* %5)
%11 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%14 = call i32 @pipe(i32* %13)
%15 = call i64 (...) @fork()
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %1
%18 = load i32, i32* %13
%19 = call i32 @close(i32 %18)
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%21 = load i32, i32* %20
%22 = call i32 @dup2(i32 %21, i32 1)
%23 = call i32 @close(i32 2)
%24 = call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32* null)
br label %25
25: ; preds = %17, %1
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 @close(i32 %27)
%29 = call i32 @wait(i32* null)
%30 = load i32, i32* %13
%31 = call i32 @readln(i32 %30, i8* %4)
%32 = load i32, i32* %13
%33 = call i32 @close(i32 %32)
ret i32 %31
}