#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 */
typedef size_t uint8_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
void *malloc(size_t);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
char toupper(char const);
char **create_upper_array(const char **from, size_t size) {
  size_t len;
  size_t i;
  uint8_t j;
  char **to;
  to = malloc(size * sizeof(char *));
  if (to == NULL) {
    fprintf(stderr, "failed to allocate memory\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < size; i++) {
    len = strlen(from[i]);
    to[i] = malloc(len * sizeof(char) + 1);
    if (to[i] == NULL) {
      fprintf(stderr, "failed to allocate memory\n");
      exit(EXIT_FAILURE);
    }
    for (j = 0; j <= len; j++)
      to[i][j] = toupper(from[i][j]);
  }
  return to;
}


x86 assembly (clang, -O0):
<create_upper_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    119f <create_upper_array+0x4f>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    128b <create_upper_array+0x13b>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
shl    $0x0,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1220 <create_upper_array+0xd0>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     1275 <create_upper_array+0x125>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1228 <create_upper_array+0xd8>
jmp    127a <create_upper_array+0x12a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a7 <create_upper_array+0x57>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_upper_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x0(,%rsi,8),%rdi
call   1060 <malloc@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     120e <create_upper_array+0xbe>
test   %r15,%r15
je     11fb <create_upper_array+0xab>
xor    %r14d,%r14d
jmp    1199 <create_upper_array+0x49>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14
cmp    %r15,%r14
je     11fb <create_upper_array+0xab>
mov    (%r12,%r14,8),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    (%rsp),%rax
mov    %rbx,(%rax,%r14,8)
test   %rbx,%rbx
je     120e <create_upper_array+0xbe>
movsbl 0x0(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,(%rbx)
test   %r13,%r13
je     1190 <create_upper_array+0x40>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%r14,8),%rax
movsbl (%rax,%rbp,1),%edi
call   1030 <toupper@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    %r13,%rbp
jbe    11e0 <create_upper_array+0x90>
jmp    1190 <create_upper_array+0x40>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"failed to allocate memory\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i8** @create_upper_array(i8** nocapture %0, i64 %1) {
%3 = shl i64 %1, 3
%4 = tail call i8* @malloc(i64 %3)
%5 = bitcast i8* %4 to i8**
%6 = icmp eq i8* %4, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = icmp eq i64 %1, 0
br i1 %8, label %44, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %7, %41
%15 = phi i64 [ %42, %41 ], [ 0, %7 ]
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%19 = add i64 %18, 1
%20 = tail call i8* @malloc(i64 %19)
%21 = getelementptr inbounds i8*, i8** %5, i64 %15
store i8* %20, i8** %21
%22 = icmp eq i8* %20, null
br i1 %22, label %27, label %23
23: ; preds = %14
%24 = load i8, i8* %17
%25 = tail call signext i8 @toupper(i8 signext %24)
store i8 %25, i8* %20
%26 = icmp eq i64 %18, 0
br i1 %26, label %41, label %32
27: ; preds = %14
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %23, %32
%33 = phi i64 [ %39, %32 ], [ 1, %23 ]
%34 = load i8*, i8** %16
%35 = getelementptr inbounds i8, i8* %34, i64 %33
%36 = load i8, i8* %35
%37 = tail call signext i8 @toupper(i8 signext %36)
%38 = getelementptr inbounds i8, i8* %20, i64 %33
store i8 %37, i8* %38
%39 = add i64 %33, 1
%40 = icmp ugt i64 %39, %18
br i1 %40, label %41, label %32
41: ; preds = %32, %23
%42 = add nuw i64 %15, 1
%43 = icmp eq i64 %42, %1
br i1 %43, label %44, label %14
44: ; preds = %41, %7
ret i8** %5
}