#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int *allocate_bytes(size_t);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ perror(char *);
size_t strtoull(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int *is;
  size_t nbytes, nints;
  if (argc < 2) {
    nints = 2;
  } else {
    nints = strtoull(argv[1], NULL, 0);
  }
  nbytes = nints * sizeof(*is);
  is = allocate_bytes(nbytes);
  if (is == NULL) {
    perror("malloc");
    exit(EXIT_FAILURE);
  }
  is[0] = 1;
  is[1] = 2;
  assert(is[0] == 1);
  assert(is[1] == 2);
  free(is);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118d <main+0x2d>
movq   $0x2,-0x28(%rbp)
jmp    11a4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtoull@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <allocate_bytes@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e2 <main+0x82>
lea    0xe31(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x2,0x4(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %edi,%eax
mov    $0x8,%edi
cmp    $0x2,%eax
jl     1181 <main+0x21>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtoull@plt>
mov    %rax,%rdi
shl    $0x2,%rdi
call   1040 <allocate_bytes@plt>
test   %rax,%rax
je     11c7 <main+0x67>
mov    %rax,%rbx
movabs $0x200000001,%rax
mov    %rax,(%rbx)
mov    $0x1,%edi
call   1060 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,0x4(%rbx)
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
lea    0xe32(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"malloc\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i64 2, i64* %8
br label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strtoull(i8* %15, i32* null, i32 0)
store i64 %16, i64* %8
br label %17
17: ; preds = %12, %11
%18 = load i64, i64* %8
%19 = mul i64 %18, 4
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = call i32* @allocate_bytes(i64 %20)
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
%29 = load i32*, i32** %6
%30 = getelementptr inbounds i32, i32* %29, i64 0
store i32 1, i32* %30
%31 = load i32*, i32** %6
%32 = getelementptr inbounds i32, i32* %31, i64 1
store i32 2, i32* %32
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i64 0
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 1
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32*, i32** %6
%40 = getelementptr inbounds i32, i32* %39, i64 1
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, 2
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i32*, i32** %6
%46 = call i32 @free(i32* %45)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
@.str = [7 x i8] c"malloc\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strtoull(i8* nocapture %6, i32* null, i32 0)
%8 = shl i64 %7, 2
br label %9
9: ; preds = %2, %4
%10 = phi i64 [ %8, %4 ], [ 8, %2 ]
%11 = tail call i32* @allocate_bytes(i64 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %9
store i32 1, i32* %11
%18 = getelementptr inbounds i32, i32* %11, i64 1
store i32 2, i32* %18
%19 = tail call i32 @assert(i32 1)
%20 = load i32, i32* %18
%21 = icmp eq i32 %20, 2
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = tail call i32 @free(i32* %11)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}