#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 */
size_t atoi(char *);
int /*<<< orphan*/ bufferOverReadUsingHeap(char *, size_t);
int /*<<< orphan*/ bufferOverReadUsingStack(char *, size_t);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  if (argc < 3)
    return 1;
  char *input = argv[2];
  size_t length = atoi(argv[1]);
  bufferOverReadUsingHeap(input, length);
  printf("\n==================================================================="
         "=======================\n\n");
  bufferOverReadUsingStack(input, length);
}


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   $0x3,-0x8(%rbp)
jge    116c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11af <main+0x6f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <bufferOverReadUsingHeap@plt>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <bufferOverReadUsingStack@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
cmp    $0x3,%edi
jl     1189 <main+0x49>
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%r14
call   1060 <atoi@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <bufferOverReadUsingHeap@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <bufferOverReadUsingStack@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [94 x i8] c"\0A==========================================================================================\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %26
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
store i8* %14, i8** %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @atoi(i8* %17)
store i64 %18, i64* %7
%19 = load i8*, i8** %6
%20 = load i64, i64* %7
%21 = call i32 @bufferOverReadUsingHeap(i8* %19, i64 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str, i64 0, i64 0))
%23 = load i8*, i8** %6
%24 = load i64, i64* %7
%25 = call i32 @bufferOverReadUsingStack(i8* %23, i64 %24)
br label %26
26: ; preds = %11, %10
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@str = [93 x i8] c"\0A==========================================================================================\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @atoi(i8* %8)
%10 = tail call i32 @bufferOverReadUsingHeap(i8* %6, i64 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([93 x i8], [93 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @bufferOverReadUsingStack(i8* %6, i64 %9)
br label %13
13: ; preds = %2, %4
%14 = phi i32 [ 0, %4 ], [ 1, %2 ]
ret i32 %14
}