#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 */
struct pbc_new {
  int dummy;
};

/* Variables and functions */
int init_pbc_env_with_dir(char *, struct pbc_new *);
struct pbc_new *pbc_new();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc == 0) {
    printf("specify folder contains .pb file plz\n");
    return -1;
  }
  char *folder = argv[1];
  struct pbc_new *env = pbc_new();
  int registered = init_pbc_env_with_dir(folder, env);
  if (registered < 0) {
    printf("register with folder failed, please check");
    return -1;
  }
  printf("%d files successfully registerd.\n", registered);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cd <main+0x9d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <pbc_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <init_pbc_env_with_dir@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11b5 <main+0x85>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cd <main+0x9d>
mov    -0x24(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     1176 <main+0x36>
mov    0x8(%rsi),%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <pbc_new@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <init_pbc_env_with_dir@plt>
test   %eax,%eax
js     1184 <main+0x44>
lea    0xebf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1197 <main+0x57>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
jmp    1192 <main+0x52>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.pbc_new = type { i32 }
@.str = [38 x i8] c"specify folder contains .pb file plz\0A\00"
@.str.1 = [42 x i8] c"register with folder failed, please check\00"
@.str.2 = [34 x i8] c"%d files successfully registerd.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.pbc_new*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %28
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = call %struct.pbc_new* (...) @pbc_new()
store %struct.pbc_new* %17, %struct.pbc_new** %7
%18 = load i8*, i8** %6
%19 = load %struct.pbc_new*, %struct.pbc_new** %7
%20 = call i32 @init_pbc_env_with_dir(i8* %18, %struct.pbc_new* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %28
25: ; preds = %13
%26 = load i32, i32* %8
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %26)
store i32 0, i32* %3
br label %28
28: ; preds = %25, %23, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.pbc_new = type { i32 }
@.str.1 = [42 x i8] c"register with folder failed, please check\00"
@.str.2 = [34 x i8] c"%d files successfully registerd.\0A\00"
@str = [37 x i8] c"specify folder contains .pb file plz\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call %struct.pbc_new* (...) @pbc_new()
%10 = tail call i32 @init_pbc_env_with_dir(i8* %8, %struct.pbc_new* %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %16
16: ; preds = %12, %14, %4
%17 = phi i32 [ -1, %4 ], [ -1, %12 ], [ 0, %14 ]
ret i32 %17
}