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

/* Variables and functions */
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ getchar();
char *pocket_auth(char *, char *);
int /*<<< orphan*/ pocket_clean();
char *pocket_get_token(char *);
int /*<<< orphan*/ pocket_init();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char **argv) {
  char *auth_token;
  char *access_token;
  char key[50];
  FILE *config;
  pocket_init();
  printf("\n Open your browser and go to:\n\n "
         "http://getpocket.com/developer/apps/new \n\n"
         " paste here the autogenerated consumer-key string: ");
  scanf("%s", key);
  getchar();
  auth_token = pocket_get_token(key);
  printf(" \nReceived token: %s\n", auth_token);
  printf("\n Enter the following URL and confirm the app (Enter when done)\n\n"
         "%s?request_token=%s&redirect_uri=%s\n\n",
         "https://getpocket.com"
         "/auth/authorize",
         auth_token, "https://github.com/anavarro/pocket-cli");
  getchar();
  access_token = pocket_auth(key, auth_token);
  config = fopen("config.h", "w");
  if (NULL == config) {
    die("Error when creating config.h file!\n");
  }
  fprintf(config,
          "#pragma once\n\n"
          "#define POCKET_KEY   \"%s\"\n"
          "#define POCKET_TOKEN \"%s\"\n\n",
          key, access_token);
  fclose(config);
  printf(" config.h file successfully created. Continue with 'make "
         "pocket-cli'\n\n");
  pocket_clean();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   10a0 <pocket_init@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1090 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x60(%rbp),%rdi
call   1050 <pocket_get_token@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdx
lea    0xe7c(%rip),%rdi
lea    0xedc(%rip),%rsi
lea    0xefa(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <pocket_auth@plt>
mov    %rax,-0x20(%rbp)
lea    0xefb(%rip),%rdi
lea    0xefd(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x68(%rbp)
xor    %eax,%eax
cmp    -0x68(%rbp),%rax
jne    1278 <main+0xc8>
lea    0xee3(%rip),%rdi
call   10c0 <die@plt>
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xeef(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xf1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10d0 <pocket_clean@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   10b0 <pocket_init@plt>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   10a0 <scanf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %r14,%rdi
call   1060 <pocket_get_token@plt>
mov    %rax,%rbx
lea    0xe7b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe80(%rip),%rdi
lea    0xee0(%rip),%rsi
lea    0xefe(%rip),%rcx
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <pocket_auth@plt>
mov    %rax,%r14
lea    0xeff(%rip),%rdi
lea    0xf01(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    126c <main+0xac>
lea    0xeef(%rip),%rdi
call   10d0 <die@plt>
lea    0xf07(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xf2e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10e0 <pocket_clean@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [127 x i8] c"\0A Open your browser and go to:\0A\0A http://getpocket.com/developer/apps/new \0A\0A paste here the autogenerated consumer-key string: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c" \0AReceived token: %s\0A\00"
@.str.3 = [103 x i8] c"\0A Enter the following URL and confirm the app (Enter when done)\0A\0A%s?request_token=%s&redirect_uri=%s\0A\0A\00"
@.str.4 = [37 x i8] c"https://getpocket.com/auth/authorize\00"
@.str.5 = [39 x i8] c"https://github.com/anavarro/pocket-cli\00"
@.str.6 = [9 x i8] c"config.h\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [36 x i8] c"Error when creating config.h file!\0A\00"
@.str.9 = [68 x i8] c"#pragma once\0A\0A#define POCKET_KEY \22%s\22\0A#define POCKET_TOKEN \22%s\22\0A\0A\00"
@.str.10 = [71 x i8] c" config.h file successfully created. Continue with 'make pocket-cli'\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [50 x i8]
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (...) @pocket_init()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 (...) @getchar()
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%16 = call i8* @pocket_get_token(i8* %15)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (...) @getchar()
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%23 = load i8*, i8** %6
%24 = call i8* @pocket_auth(i8* %22, i8* %23)
store i8* %24, i8** %7
%25 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %25, i32** %9
%26 = load i32*, i32** %9
%27 = icmp eq i32* null, %26
br i1 %27, label %28, label %30
28: ; preds = %2
%29 = call i32 @die(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %30
30: ; preds = %28, %2
%31 = load i32*, i32** %9
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%33 = load i8*, i8** %7
%34 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.9, i64 0, i64 0), i8* %32, i8* %33)
%35 = load i32*, i32** %9
%36 = call i32 @fclose(i32* %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.10, i64 0, i64 0))
%38 = call i32 (...) @pocket_clean()
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [127 x i8] c"\0A Open your browser and go to:\0A\0A http://getpocket.com/developer/apps/new \0A\0A paste here the autogenerated consumer-key string: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c" \0AReceived token: %s\0A\00"
@.str.3 = [103 x i8] c"\0A Enter the following URL and confirm the app (Enter when done)\0A\0A%s?request_token=%s&redirect_uri=%s\0A\0A\00"
@.str.4 = [37 x i8] c"https://getpocket.com/auth/authorize\00"
@.str.5 = [39 x i8] c"https://github.com/anavarro/pocket-cli\00"
@.str.6 = [9 x i8] c"config.h\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [36 x i8] c"Error when creating config.h file!\0A\00"
@.str.9 = [68 x i8] c"#pragma once\0A\0A#define POCKET_KEY \22%s\22\0A#define POCKET_TOKEN \22%s\22\0A\0A\00"
@str = [70 x i8] c" config.h file successfully created. Continue with 'make pocket-cli'\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @pocket_init()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([127 x i8], [127 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = call i32 (...) @getchar()
%9 = call i8* @pocket_get_token(i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([103 x i8], [103 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (...) @getchar()
%13 = call i8* @pocket_auth(i8* %4, i8* %9)
%14 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @die(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.9, i64 0, i64 0), i8* %4, i8* %13)
%20 = call i32 @fclose(i32* %14)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%22 = call i32 (...) @pocket_clean()
ret i32 0
}