#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 */
char *gpthextptr(char *);
int snapshot_append(char *, char *, char *);
int snapshot_copy(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int add_snapshot(char *revision, char *target, char *directory) {
  char *extension = NULL;
  int result = 0;
  if ((extension = gpthextptr(revision)) == NULL)
    return -1;
  if (strcmp(extension, "snapshot") == 0)
    result = snapshot_copy(revision, target, directory);
  else if (strcmp(extension, "diff") == 0)
    result = snapshot_append(revision, target, directory);
  else
    result = -1;
  return result;
}


x86 assembly (clang, -O0):
<add_snapshot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <gpthextptr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1186 <add_snapshot+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fe <add_snapshot+0xbe>
mov    -0x28(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b9 <add_snapshot+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <snapshot_copy@plt>
mov    %eax,-0x2c(%rbp)
jmp    11f8 <add_snapshot+0xb8>
mov    -0x28(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ec <add_snapshot+0xac>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <snapshot_append@plt>
mov    %eax,-0x2c(%rbp)
jmp    11f3 <add_snapshot+0xb3>
movl   $0xffffffff,-0x2c(%rbp)
jmp    11f8 <add_snapshot+0xb8>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_snapshot>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1060 <gpthextptr@plt>
test   %rax,%rax
je     1186 <add_snapshot+0x46>
mov    %rax,%rbx
lea    0xe9b(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1197 <add_snapshot+0x57>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b0 <add_snapshot+0x70>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <snapshot_copy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <snapshot_append@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"snapshot\00"
@.str.1 = [5 x i8] c"diff\00"
define i32 @add_snapshot(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* null, i8** %8
store i32 0, i32* %9
%10 = load i8*, i8** %5
%11 = call i8* @gpthextptr(i8* %10)
store i8* %11, i8** %8
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 -1, i32* %4
br label %36
14: ; preds = %3
%15 = load i8*, i8** %8
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = call i32 @snapshot_copy(i8* %19, i8* %20, i8* %21)
store i32 %22, i32* %9
br label %34
23: ; preds = %14
%24 = load i8*, i8** %8
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = load i8*, i8** %5
%29 = load i8*, i8** %6
%30 = load i8*, i8** %7
%31 = call i32 @snapshot_append(i8* %28, i8* %29, i8* %30)
store i32 %31, i32* %9
br label %33
32: ; preds = %23
store i32 -1, i32* %9
br label %33
33: ; preds = %32, %27
br label %34
34: ; preds = %33, %18
%35 = load i32, i32* %9
store i32 %35, i32* %4
br label %36
36: ; preds = %34, %13
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [9 x i8] c"snapshot\00"
@.str.1 = [5 x i8] c"diff\00"
define i32 @add_snapshot(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @gpthextptr(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @snapshot_copy(i8* %0, i8* %1, i8* %2)
br label %16
11: ; preds = %6
%12 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @snapshot_append(i8* %0, i8* %1, i8* %2)
br label %16
16: ; preds = %9, %14, %11, %3
%17 = phi i32 [ -1, %3 ], [ %10, %9 ], [ %15, %14 ], [ -1, %11 ]
ret i32 %17
}