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

/* Variables and functions */
int MAXPATHLEN;
char *getcwd(char *, int);
int simple_tar_extract_to(char const *, char *);
int simple_tar_extract(const char *tarfile) {
  char cwd[MAXPATHLEN];
  char *cwdp;
  cwdp = getcwd(cwd, sizeof(cwd));
  if (!cwdp) {
    return -1;
  }
  return simple_tar_extract_to(tarfile, cwd);
}


x86 assembly (clang, -O0):
<simple_tar_extract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    %eax,%esi
call   1030 <getcwd@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1181 <simple_tar_extract+0x61>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1198 <simple_tar_extract+0x78>
mov    -0x38(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1040 <simple_tar_extract_to@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_tar_extract>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2eb7(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <getcwd@plt>
test   %rax,%rax
je     1161 <simple_tar_extract+0x41>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <simple_tar_extract_to@plt>
jmp    1166 <simple_tar_extract+0x46>
mov    $0xffffffff,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
define i32 @simple_tar_extract(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i32, i32* @MAXPATHLEN
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca i8, i64 %9
store i64 %9, i64* %5
%12 = trunc i64 %9 to i32
%13 = call i8* @getcwd(i8* %11, i32 %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %1
store i32 -1, i32* %2
store i32 1, i32* %7
br label %20
17: ; preds = %1
%18 = load i8*, i8** %3
%19 = call i32 @simple_tar_extract_to(i8* %18, i8* %11)
store i32 %19, i32* %2
store i32 1, i32* %7
br label %20
20: ; preds = %17, %16
%21 = load i8*, i8** %4
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
define i32 @simple_tar_extract(i8* %0) {
%2 = load i32, i32* @MAXPATHLEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i8* @getcwd(i8* %4, i32 %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @simple_tar_extract_to(i8* %0, i8* %4)
br label %9
9: ; preds = %1, %7
%10 = phi i32 [ %8, %7 ], [ -1, %1 ]
ret i32 %10
}