#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 /*<<< orphan*/ download_config();
int /*<<< orphan*/ getenv(char *);
int sscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ upload_config();
int main(int argc, char **argv) {
  int i;
  if (sscanf(getenv("QUERY_STRING"), "save=%d", &i) == 1) {
    download_config();
  }
  if (sscanf(getenv("QUERY_STRING"), "restore=%d", &i) == 1) {
    upload_config();
  }
  return 0;
}


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)
lea    0xea3(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
lea    0xea2(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    1184 <main+0x44>
mov    $0x0,%al
call   1040 <download_config@plt>
lea    0xe75(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
lea    0xe7c(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11b2 <main+0x72>
mov    $0x0,%al
call   1050 <upload_config@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
lea    0xeb9(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %eax,%edi
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    116c <main+0x2c>
xor    %eax,%eax
call   1040 <download_config@plt>
lea    0xe8d(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe96(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %eax,%edi
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    1197 <main+0x57>
xor    %eax,%eax
call   1050 <upload_config@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [8 x i8] c"save=%d\00"
@.str.2 = [11 x i8] c"restore=%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @sscanf(i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @download_config()
br label %12
12: ; preds = %10, %2
%13 = call i32 @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @sscanf(i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (...) @upload_config()
br label %18
18: ; preds = %16, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [8 x i8] c"save=%d\00"
@.str.2 = [11 x i8] c"restore=%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @sscanf(i32 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @download_config()
br label %10
10: ; preds = %8, %2
%11 = call i32 @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @sscanf(i32 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (...) @upload_config()
br label %16
16: ; preds = %14, %10
ret i32 0
}