#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 */
scalar_t__ EEXIST;
int /*<<< orphan*/ EX_OK;
int /*<<< orphan*/ EX_OSERR;
int /*<<< orphan*/ call_gnupg_gen();
int chmod(char *, int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
char *gnupghome_dir();
int mkdir(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  (void)argv;
  if (argc != 1)
    usage();
  char *gpghome = gnupghome_dir();
  if (mkdir(gpghome, 0700) == -1) {
    if (errno != EEXIST) {
      fprintf(stderr, "%s: mkdir %s: %s\n", "prettykey", "GnuPG",
              strerror(errno));
      exit(EX_OSERR);
    }
  }
  if (chmod(gpghome, 0700) == -1) {
    fprintf(stderr, "%s: chmod %s: %s\n", "prettykey", "GnuPG",
            strerror(errno));
    exit(EX_OSERR);
  }
  free(gpghome);
  gpghome = NULL;
  call_gnupg_gen();
  exit(EX_OK);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11b7 <main+0x27>
mov    $0x0,%al
call   1080 <usage@plt>
mov    $0x0,%al
call   1070 <gnupghome_dir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1c0,%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    1241 <main+0xb1>
mov    0x2df0(%rip),%rax
mov    (%rax),%rax
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%rax
je     123c <main+0xac>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2dca(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%r8
lea    0xde5(%rip),%rsi
lea    0xdf0(%rip),%rdx
lea    0xdf3(%rip),%rcx
call   1060 <fprintf@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    1241 <main+0xb1>
mov    -0x18(%rbp),%rdi
mov    $0x1c0,%esi
call   1090 <chmod@plt>
cmp    $0xffffffff,%eax
jne    12a1 <main+0x111>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d65(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%r8
lea    0xda2(%rip),%rsi
lea    0xd8b(%rip),%rdx
lea    0xd8e(%rip),%rcx
call   1060 <fprintf@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1050 <call_gnupg_gen@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
je     119d <main+0xd>
xor    %eax,%eax
call   1080 <usage@plt>
xor    %eax,%eax
call   1070 <gnupghome_dir@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1c0,%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    11cf <main+0x3f>
mov    0x2e10(%rip),%rax
mov    (%rax),%rdi
mov    0x2e16(%rip),%rax
cmp    (%rax),%rdi
jne    121f <main+0x8f>
mov    %rbx,%rdi
mov    $0x1c0,%esi
call   1090 <chmod@plt>
cmp    $0xffffffff,%eax
jne    1202 <main+0x72>
mov    0x2df0(%rip),%rax
mov    (%rax),%ebx
mov    0x2ddf(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
lea    0xe22(%rip),%rsi
jmp    1234 <main+0xa4>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1050 <call_gnupg_gen@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%ebx
call   10b0 <strerror@plt>
lea    0xdcc(%rip),%rsi
lea    0xdd7(%rip),%rdx
lea    0xdda(%rip),%rcx
mov    %ebx,%edi
mov    %rax,%r8
call   1060 <fprintf@plt>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@EEXIST = global i64 0
@stderr = global i32 0
@.str = [18 x i8] c"%s: mkdir %s: %s\0A\00"
@.str.1 = [10 x i8] c"prettykey\00"
@.str.2 = [6 x i8] c"GnuPG\00"
@EX_OSERR = global i32 0
@.str.3 = [18 x i8] c"%s: chmod %s: %s\0A\00"
@EX_OK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
br label %12
12: ; preds = %10, %2
%13 = call i8* (...) @gnupghome_dir()
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 @mkdir(i8* %14, i32 448)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i64, i64* @errno
%19 = load i64, i64* @EEXIST
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = load i64, i64* @errno
%24 = call i8* @strerror(i64 %23)
%25 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EX_OSERR
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
br label %29
29: ; preds = %28, %12
%30 = load i8*, i8** %6
%31 = call i32 @chmod(i8* %30, i32 448)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i64, i64* @errno
%36 = call i8* @strerror(i64 %35)
%37 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EX_OSERR
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %29
%41 = load i8*, i8** %6
%42 = call i32 @free(i8* %41)
store i8* null, i8** %6
%43 = call i32 (...) @call_gnupg_gen()
%44 = load i32, i32* @EX_OK
%45 = call i32 @exit(i32 %44)
unreachable
}

LLVM IR (-O2):
@errno = global i64 0
@EEXIST = global i64 0
@stderr = global i32 0
@.str = [18 x i8] c"%s: mkdir %s: %s\0A\00"
@.str.1 = [10 x i8] c"prettykey\00"
@.str.2 = [6 x i8] c"GnuPG\00"
@EX_OSERR = global i32 0
@.str.3 = [18 x i8] c"%s: chmod %s: %s\0A\00"
@EX_OK = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = tail call i8* (...) @gnupghome_dir()
%8 = tail call i32 @mkdir(i8* %7, i32 448)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i64, i64* @errno
%12 = load i64, i64* @EEXIST
%13 = icmp eq i64 %11, %12
br i1 %13, label %20, label %14
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = tail call i8* @strerror(i64 %11)
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EX_OSERR
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %10, %6
%21 = tail call i32 @chmod(i8* %7, i32 448)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = load i64, i64* @errno
%26 = tail call i8* @strerror(i64 %25)
%27 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @EX_OSERR
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %20
%31 = tail call i32 @free(i8* %7)
%32 = tail call i32 (...) @call_gnupg_gen()
%33 = load i32, i32* @EX_OK
%34 = tail call i32 @exit(i32 %33)
unreachable
}