#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
void *malloc(unsigned int);
int /*<<< orphan*/ stderr;
char **alloc_argv(unsigned rows) {
  char **matrix = malloc(rows * sizeof(char *));
  if (matrix == NULL) {
    fprintf(stderr, "malloc failed!\n");
  }
  if (!matrix)
    abort();
  for (unsigned row = 0; row < rows; row++) {
    matrix[row] = malloc(rows * sizeof(char *));
    if (matrix[row] == NULL) {
      fprintf(stderr, "malloc failed!\n");
    }
    matrix[row] = "\0";
    if (!matrix[row])
      abort();
  }
  return matrix;
}


x86 assembly (clang, -O0):
<alloc_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116d <alloc_argv+0x3d>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    117f <alloc_argv+0x4f>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1213 <alloc_argv+0xe3>
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
jne    11d5 <alloc_argv+0xa5>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
lea    0xe2d(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
cmpq   $0x0,(%rax,%rcx,8)
jne    1200 <alloc_argv+0xd0>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1205 <alloc_argv+0xd5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1186 <alloc_argv+0x56>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_argv>:
push   %rbx
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     127f <alloc_argv+0x14f>
test   %ebx,%ebx
je     127d <alloc_argv+0x14d>
mov    %ebx,%ecx
cmp    $0x3,%ebx
ja     115e <alloc_argv+0x2e>
xor    %edx,%edx
jmp    1269 <alloc_argv+0x139>
mov    %ecx,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rbx
mov    %rbx,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%r8d
and    $0x7,%r8d
cmp    $0x1c,%rbx
jae    1186 <alloc_argv+0x56>
xor    %ebx,%ebx
jmp    1225 <alloc_argv+0xf5>
and    $0xfffffffffffffff8,%rdi
xor    %ebx,%ebx
lea    0xe7d(%rip),%rsi
movq   %rsi,%xmm0
pshufd $0x44,%xmm0,%xmm0
nopl   (%rax)
movdqu %xmm0,(%rax,%rbx,8)
movdqu %xmm0,0x10(%rax,%rbx,8)
movdqu %xmm0,0x20(%rax,%rbx,8)
movdqu %xmm0,0x30(%rax,%rbx,8)
movdqu %xmm0,0x40(%rax,%rbx,8)
movdqu %xmm0,0x50(%rax,%rbx,8)
movdqu %xmm0,0x60(%rax,%rbx,8)
movdqu %xmm0,0x70(%rax,%rbx,8)
movdqu %xmm0,0x80(%rax,%rbx,8)
movdqu %xmm0,0x90(%rax,%rbx,8)
movdqu %xmm0,0xa0(%rax,%rbx,8)
movdqu %xmm0,0xb0(%rax,%rbx,8)
movdqu %xmm0,0xc0(%rax,%rbx,8)
movdqu %xmm0,0xd0(%rax,%rbx,8)
movdqu %xmm0,0xe0(%rax,%rbx,8)
movdqu %xmm0,0xf0(%rax,%rbx,8)
add    $0x20,%rbx
add    $0xfffffffffffffff8,%rdi
jne    11a0 <alloc_argv+0x70>
test   %r8,%r8
je     1264 <alloc_argv+0x134>
lea    (%rax,%rbx,8),%rdi
add    $0x10,%rdi
shl    $0x5,%r8
xor    %ebx,%ebx
lea    0xdd1(%rip),%rsi
movq   %rsi,%xmm0
pshufd $0x44,%xmm0,%xmm0
nopl   0x0(%rax)
movdqu %xmm0,-0x10(%rdi,%rbx,1)
movdqu %xmm0,(%rdi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r8
jne    1250 <alloc_argv+0x120>
cmp    %rcx,%rdx
je     127d <alloc_argv+0x14d>
lea    0xda0(%rip),%rsi
mov    %rsi,(%rax,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1270 <alloc_argv+0x140>
pop    %rbx
ret
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
lea    0xd71(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"malloc failed!\0A\00"
@.str.1 = [2 x i8] zeroinitializer
define i8** @alloc_argv(i32 %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = zext i32 %5 to i64
%7 = mul i64 %6, 8
%8 = trunc i64 %7 to i32
%9 = call i8* @malloc(i32 %8)
%10 = bitcast i8* %9 to i8**
store i8** %10, i8*** %3
%11 = load i8**, i8*** %3
%12 = icmp eq i8** %11, null
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %13, %1
%17 = load i8**, i8*** %3
%18 = icmp ne i8** %17, null
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %16
store i32 0, i32* %4
br label %22
22: ; preds = %59, %21
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = icmp ult i32 %23, %24
br i1 %25, label %26, label %62
26: ; preds = %22
%27 = load i32, i32* %2
%28 = zext i32 %27 to i64
%29 = mul i64 %28, 8
%30 = trunc i64 %29 to i32
%31 = call i8* @malloc(i32 %30)
%32 = load i8**, i8*** %3
%33 = load i32, i32* %4
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
store i8* %31, i8** %35
%36 = load i8**, i8*** %3
%37 = load i32, i32* %4
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %26
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %45
45: ; preds = %42, %26
%46 = load i8**, i8*** %3
%47 = load i32, i32* %4
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %49
%50 = load i8**, i8*** %3
%51 = load i32, i32* %4
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = icmp ne i8* %54, null
br i1 %55, label %58, label %56
56: ; preds = %45
%57 = call i32 (...) @abort()
unreachable
58: ; preds = %45
br label %59
59: ; preds = %58
%60 = load i32, i32* %4
%61 = add i32 %60, 1
store i32 %61, i32* %4
br label %22
62: ; preds = %22
%63 = load i8**, i8*** %3
ret i8** %63
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"malloc failed!\0A\00"
@.str.1 = [2 x i8] zeroinitializer
define i8** @alloc_argv(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call i8* @malloc(i32 %2)
%4 = bitcast i8* %3 to i8**
%5 = icmp eq i8* %3, null
br i1 %5, label %82, label %6
6: ; preds = %1
%7 = icmp eq i32 %0, 0
br i1 %7, label %86, label %8
8: ; preds = %6
%9 = zext i32 %0 to i64
%10 = icmp ult i32 %0, 4
br i1 %10, label %11, label %13
11: ; preds = %80, %8
%12 = phi i64 [ 0, %8 ], [ %14, %80 ]
br label %87
13: ; preds = %8
%14 = and i64 %9, 4294967292
%15 = add nsw i64 %14, -4
%16 = lshr exact i64 %15, 2
%17 = add nuw nsw i64 %16, 1
%18 = and i64 %17, 7
%19 = icmp ult i64 %15, 28
br i1 %19, label %67, label %20
20: ; preds = %13
%21 = and i64 %17, 9223372036854775800
br label %22
22: ; preds = %22, %20
%23 = phi i64 [ 0, %20 ], [ %64, %22 ]
%24 = phi i64 [ 0, %20 ], [ %65, %22 ]
%25 = getelementptr inbounds i8*, i8** %4, i64 %23
%26 = bitcast i8** %25 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %26
%27 = getelementptr inbounds i8*, i8** %25, i64 2
%28 = bitcast i8** %27 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %28
%29 = or i64 %23, 4
%30 = getelementptr inbounds i8*, i8** %4, i64 %29
%31 = bitcast i8** %30 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %31
%32 = getelementptr inbounds i8*, i8** %30, i64 2
%33 = bitcast i8** %32 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %33
%34 = or i64 %23, 8
%35 = getelementptr inbounds i8*, i8** %4, i64 %34
%36 = bitcast i8** %35 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %36
%37 = getelementptr inbounds i8*, i8** %35, i64 2
%38 = bitcast i8** %37 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %38
%39 = or i64 %23, 12
%40 = getelementptr inbounds i8*, i8** %4, i64 %39
%41 = bitcast i8** %40 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %41
%42 = getelementptr inbounds i8*, i8** %40, i64 2
%43 = bitcast i8** %42 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %43
%44 = or i64 %23, 16
%45 = getelementptr inbounds i8*, i8** %4, i64 %44
%46 = bitcast i8** %45 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %46
%47 = getelementptr inbounds i8*, i8** %45, i64 2
%48 = bitcast i8** %47 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %48
%49 = or i64 %23, 20
%50 = getelementptr inbounds i8*, i8** %4, i64 %49
%51 = bitcast i8** %50 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %51
%52 = getelementptr inbounds i8*, i8** %50, i64 2
%53 = bitcast i8** %52 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %53
%54 = or i64 %23, 24
%55 = getelementptr inbounds i8*, i8** %4, i64 %54
%56 = bitcast i8** %55 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %56
%57 = getelementptr inbounds i8*, i8** %55, i64 2
%58 = bitcast i8** %57 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %58
%59 = or i64 %23, 28
%60 = getelementptr inbounds i8*, i8** %4, i64 %59
%61 = bitcast i8** %60 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %61
%62 = getelementptr inbounds i8*, i8** %60, i64 2
%63 = bitcast i8** %62 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %63
%64 = add nuw i64 %23, 32
%65 = add i64 %24, 8
%66 = icmp eq i64 %65, %21
br i1 %66, label %67, label %22
67: ; preds = %22, %13
%68 = phi i64 [ 0, %13 ], [ %64, %22 ]
%69 = icmp eq i64 %18, 0
br i1 %69, label %80, label %70
70: ; preds = %67, %70
%71 = phi i64 [ %77, %70 ], [ %68, %67 ]
%72 = phi i64 [ %78, %70 ], [ 0, %67 ]
%73 = getelementptr inbounds i8*, i8** %4, i64 %71
%74 = bitcast i8** %73 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %74
%75 = getelementptr inbounds i8*, i8** %73, i64 2
%76 = bitcast i8** %75 to <2 x i8*>*
store <2 x i8*> <i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)>, <2 x i8*>* %76
%77 = add nuw i64 %71, 4
%78 = add i64 %72, 1
%79 = icmp eq i64 %78, %18
br i1 %79, label %80, label %70
80: ; preds = %70, %67
%81 = icmp eq i64 %14, %9
br i1 %81, label %86, label %11
82: ; preds = %1
%83 = load i32, i32* @stderr
%84 = tail call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%85 = tail call i32 (...) @abort()
unreachable
86: ; preds = %87, %80, %6
ret i8** %4
87: ; preds = %11, %87
%88 = phi i64 [ %90, %87 ], [ %12, %11 ]
%89 = getelementptr inbounds i8*, i8** %4, i64 %88
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %89
%90 = add nuw nsw i64 %88, 1
%91 = icmp eq i64 %90, %9
br i1 %91, label %86, label %87
}