#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*/ free(char *);
char *malloc(int);
int main(int argc, const char *argv[]) {
  char *ptr = NULL;
  int i;
  for (i; i < argc + 1; i++) {
    if (argv[i][0] == '1') {
      ptr = malloc(1);
    } else {
      if (i == 0) {
        ptr = malloc(42);
      } else {
        ptr = malloc(56);
      }
    }
  }
  if (ptr)
    free(ptr);
}


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)
movq   $0x0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11bd <main+0x9d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    117a <main+0x5a>
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
jmp    11aa <main+0x8a>
cmpl   $0x0,-0x1c(%rbp)
jne    1197 <main+0x77>
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
jmp    11a5 <main+0x85>
mov    $0x38,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
jmp    11aa <main+0x8a>
jmp    11af <main+0x8f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <main+0x1e>
cmpq   $0x0,-0x18(%rbp)
je     11d1 <main+0xb1>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    (%rsi),%rax
cmpb   $0x31,(%rax)
jne    1130 <main+0x10>
mov    $0x1,%edi
jmp    1135 <main+0x15>
mov    $0x2a,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1147 <main+0x27>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%8 = load i32, i32* %7
br label %9
9: ; preds = %35, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %38
14: ; preds = %9
%15 = load i8**, i8*** %5
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 49
br i1 %23, label %24, label %26
24: ; preds = %14
%25 = call i8* @malloc(i32 1)
store i8* %25, i8** %6
br label %34
26: ; preds = %14
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i8* @malloc(i32 42)
store i8* %30, i8** %6
br label %33
31: ; preds = %26
%32 = call i8* @malloc(i32 56)
store i8* %32, i8** %6
br label %33
33: ; preds = %31, %29
br label %34
34: ; preds = %33, %24
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %9
38: ; preds = %9
%39 = load i8*, i8** %6
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %6
%43 = call i32 @free(i8* %42)
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 49
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
br label %10
8: ; preds = %2
%9 = tail call dereferenceable_or_null(42) i8* @malloc(i32 42)
br label %10
10: ; preds = %6, %8
%11 = phi i8* [ %7, %6 ], [ %9, %8 ]
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @free(i8* %11)
br label %15
15: ; preds = %13, %10
ret i32 0
}