#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 atoi(char *);
int /*<<< orphan*/ decode(char *, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int key;
  if (argc == 2) {
    key = atoi(argv[1]);
  } else {
    key = 0;
  }
  if (key < 1) {
    printf("You should enter a valid positive integer as argument\n");
    return 1;
  }
  char text[256];
  fgets(text, 256, stdin);
  decode(text, key);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1178 <main+0x38>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x3f>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    11a1 <main+0x61>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d1 <main+0x91>
lea    -0x120(%rbp),%rdi
mov    0x2e39(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1040 <fgets@plt>
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <decode@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
cmp    $0x2,%edi
jne    1185 <main+0x45>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
test   %eax,%eax
jle    1185 <main+0x45>
mov    %eax,%ebx
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <decode@plt>
xor    %eax,%eax
jmp    1196 <main+0x56>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [55 x i8] c"You should enter a valid positive integer as argument\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
br label %16
15: ; preds = %2
store i32 0, i32* %6
br label %16
16: ; preds = %15, %10
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %28
21: ; preds = %16
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i32 @fgets(i8* %22, i32 256, i32 %23)
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%26 = load i32, i32* %6
%27 = call i32 @decode(i8* %25, i32 %26)
store i32 0, i32* %3
br label %28
28: ; preds = %21, %19
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [54 x i8] c"You should enter a valid positive integer as argument\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2, %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
br label %17
12: ; preds = %5
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 256, i32 %14)
%16 = call i32 @decode(i8* %13, i32 %8)
br label %17
17: ; preds = %12, %10
%18 = phi i32 [ 1, %10 ], [ 0, %12 ]
ret i32 %18
}