#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ db_query(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ error(char *);
char *map_file(char *, size_t *);
int /*<<< orphan*/ printf(char *);
char *source_get_file_revision(char const *, char *);
scalar_t__ state_add_revision(char const *);
scalar_t__ state_create();
int /*<<< orphan*/ state_destroy();
int /*<<< orphan*/ unmap_file();
int seed(const char *source, const char *current, int argc, char *argv[]) {
  int retval = EXIT_SUCCESS;
  const char *sfile = NULL, *srev = NULL;
  size_t size;
  (void)current;
  (void)argc;
  if (!argv[0])
    goto err;
  sfile = map_file(argv[0], &size);
  if (!sfile)
    goto err;
  do {
    printf(("Running seed file...\n"));
  } while (0);
  ;
  if (db_query(sfile, NULL, NULL))
    goto err;
  if (state_create())
    goto err;
  if (!(srev = source_get_file_revision(source, argv[0])))
    goto ret;
  if (state_add_revision(srev)) {
    state_destroy();
    error("seed: unable to set current revision");
    goto err;
  }
ret:
  unmap_file();
  return retval;
err:
  retval = EXIT_FAILURE;
  goto ret;
}


x86 assembly (clang, -O0):
<seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11d6 <seed+0x46>
jmp    12a3 <seed+0x113>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <map_file@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11fa <seed+0x6a>
jmp    12a3 <seed+0x113>
jmp    11ff <seed+0x6f>
lea    0xdfa(%rip),%rdi
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10a0 <db_query@plt>
cmp    $0x0,%rax
je     122a <seed+0x9a>
jmp    12a3 <seed+0x113>
mov    $0x0,%al
call   1080 <state_create@plt>
cmp    $0x0,%rax
je     1240 <seed+0xb0>
jmp    12a3 <seed+0x113>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
call   1040 <source_get_file_revision@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1263 <seed+0xd3>
jmp    1293 <seed+0x103>
mov    -0x38(%rbp),%rdi
call   1030 <state_add_revision@plt>
cmp    $0x0,%rax
je     128e <seed+0xfe>
mov    $0x0,%al
call   10b0 <state_destroy@plt>
lea    0xd92(%rip),%rdi
call   1090 <error@plt>
jmp    12a3 <seed+0x113>
jmp    1293 <seed+0x103>
mov    $0x0,%al
call   1070 <unmap_file@plt>
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1293 <seed+0x103>

x86 assembly (clang, -O2):
<seed>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rcx),%rdi
test   %rdi,%rdi
je     1218 <seed+0x88>
mov    %rcx,%rbx
mov    0x2e2c(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rsi
call   1060 <map_file@plt>
test   %rax,%rax
je     1218 <seed+0x88>
mov    %rax,%rbp
lea    0xe5f(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <db_query@plt>
test   %rax,%rax
jne    1218 <seed+0x88>
xor    %eax,%eax
call   1080 <state_create@plt>
test   %rax,%rax
jne    1218 <seed+0x88>
mov    (%rbx),%rsi
mov    %r14,%rdi
call   1050 <source_get_file_revision@plt>
test   %rax,%rax
je     1222 <seed+0x92>
mov    %rax,%rdi
call   1030 <state_add_revision@plt>
test   %rax,%rax
je     1222 <seed+0x92>
xor    %eax,%eax
call   10b0 <state_destroy@plt>
lea    0xded(%rip),%rdi
call   1090 <error@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%r15d
xor    %eax,%eax
call   1070 <unmap_file@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [22 x i8] c"Running seed file...\0A\00"
@.str.1 = [37 x i8] c"seed: unable to set current revision\00"
@EXIT_FAILURE = global i32 0
define i32 @seed(i8* %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%13 = load i32, i32* @EXIT_SUCCESS
store i32 %13, i32* %9
store i8* null, i8** %10
store i8* null, i8** %11
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = load i8**, i8*** %8
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %4
br label %60
21: ; preds = %4
%22 = load i8**, i8*** %8
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i8* @map_file(i8* %24, i64* %12)
store i8* %25, i8** %10
%26 = load i8*, i8** %10
%27 = icmp ne i8* %26, null
br i1 %27, label %29, label %28
28: ; preds = %21
br label %60
29: ; preds = %21
br label %30
30: ; preds = %29
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30
%33 = load i8*, i8** %10
%34 = call i64 @db_query(i8* %33, i32* null, i32* null)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
br label %60
37: ; preds = %32
%38 = call i64 (...) @state_create()
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %37
br label %60
41: ; preds = %37
%42 = load i8*, i8** %5
%43 = load i8**, i8*** %8
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = call i8* @source_get_file_revision(i8* %42, i8* %45)
store i8* %46, i8** %11
%47 = icmp ne i8* %46, null
br i1 %47, label %49, label %48
48: ; preds = %41
br label %57
49: ; preds = %41
%50 = load i8*, i8** %11
%51 = call i64 @state_add_revision(i8* %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = call i32 (...) @state_destroy()
%55 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %60
56: ; preds = %49
br label %57
57: ; preds = %60, %56, %48
%58 = call i32 (...) @unmap_file()
%59 = load i32, i32* %9
ret i32 %59
60: ; preds = %53, %40, %36, %28, %20
%61 = load i32, i32* @EXIT_FAILURE
store i32 %61, i32* %9
br label %57
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str.1 = [37 x i8] c"seed: unable to set current revision\00"
@EXIT_FAILURE = global i32 0
@str = [21 x i8] c"Running seed file...\00"
define i32 @seed(i8* %0, i8* nocapture readnone %1, i32 %2, i8** nocapture %3) {
%5 = alloca i64
%6 = load i32, i32* @EXIT_SUCCESS
%7 = bitcast i64* %5 to i8*
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %33, label %10
10: ; preds = %4
%11 = call i8* @map_file(i8* %8, i64* %5)
%12 = icmp eq i8* %11, null
br i1 %12, label %33, label %13
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%15 = call i64 @db_query(i8* %11, i32* null, i32* null)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = call i64 (...) @state_create()
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = call i8* @source_get_file_revision(i8* %0, i8* %21)
%23 = icmp eq i8* %22, null
br i1 %23, label %30, label %24
24: ; preds = %20
%25 = call i64 @state_add_revision(i8* %22)
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = call i32 (...) @state_destroy()
%29 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %33
30: ; preds = %24, %20, %33
%31 = phi i32 [ %34, %33 ], [ %6, %24 ], [ %6, %20 ]
%32 = call i32 (...) @unmap_file()
ret i32 %31
33: ; preds = %17, %13, %10, %4, %27
%34 = load i32, i32* @EXIT_FAILURE
br label %30
}