#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 */
scalar_t__ malloc(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char **write_array_type(int dimension, int i, char type_array[][500]) {
  char **type_out = (char **)malloc(dimension * sizeof(char *));
  char integer_type[500];
  char varchar_type[500];
  char float_type[500];
  char table_type[500];
  strcpy(integer_type, "INT");
  strcpy(varchar_type, "VARCHAR");
  strcpy(float_type, "FLOAT");
  strcpy(table_type, "TABLE");
  for (i = 0; i < dimension; i++) {
    if ((strcmp(type_array[i], table_type)) == 0) {
      type_out[i] = "table";
    }
    if ((strcmp(type_array[i], integer_type)) == 0) {
      type_out[i] = "int";
    }
    if ((strcmp(type_array[i], varchar_type)) == 0) {
      type_out[i] = "String";
    }
    if ((strcmp(type_array[i], float_type)) == 0) {
      type_out[i] = "float";
    }
  }
  return type_out;
}


x86 assembly (clang, -O0):
<write_array_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x610(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x810(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12b6 <write_array_type+0x186>
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
imul   $0x1f4,%rax,%rax
add    %rax,%rdi
lea    -0x810(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f2 <write_array_type+0xc2>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
lea    0xe2a(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
imul   $0x1f4,%rax,%rax
add    %rax,%rdi
lea    -0x210(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122d <write_array_type+0xfd>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
lea    0xdf5(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
imul   $0x1f4,%rax,%rax
add    %rax,%rdi
lea    -0x410(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1268 <write_array_type+0x138>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
lea    0xdbe(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
imul   $0x1f4,%rax,%rax
add    %rax,%rdi
lea    -0x610(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a3 <write_array_type+0x173>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
lea    0xd8a(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
jmp    12a8 <write_array_type+0x178>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ab <write_array_type+0x7b>
mov    -0x18(%rbp),%rax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_array_type>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7f8,%rsp
mov    %rdx,%rbx
mov    %edi,%ebp
lea    0x0(,%rbp,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xea4(%rip),%rsi
lea    0x600(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe94(%rip),%rsi
lea    0x400(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe88(%rip),%rsi
lea    0x200(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe7a(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
test   %ebp,%ebp
jle    1246 <write_array_type+0x116>
mov    %ebp,%r15d
xor    %r12d,%r12d
lea    0x400(%rsp),%r13
lea    0x200(%rsp),%rbp
jmp    11d0 <write_array_type+0xa0>
add    $0x1,%r12
add    $0x1f4,%rbx
cmp    %r12,%r15
je     1246 <write_array_type+0x116>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11eb <write_array_type+0xbb>
lea    0xe31(%rip),%rax
mov    %rax,(%r14,%r12,8)
mov    %rbx,%rdi
lea    0x600(%rsp),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    120b <write_array_type+0xdb>
lea    0xe17(%rip),%rax
mov    %rax,(%r14,%r12,8)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1226 <write_array_type+0xf6>
lea    0xe00(%rip),%rax
mov    %rax,(%r14,%r12,8)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11c0 <write_array_type+0x90>
lea    0xdec(%rip),%rax
mov    %rax,(%r14,%r12,8)
jmp    11c0 <write_array_type+0x90>
mov    %r14,%rax
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"INT\00"
@.str.1 = [8 x i8] c"VARCHAR\00"
@.str.2 = [6 x i8] c"FLOAT\00"
@.str.3 = [6 x i8] c"TABLE\00"
@.str.4 = [6 x i8] c"table\00"
@.str.5 = [4 x i8] c"int\00"
@.str.6 = [7 x i8] c"String\00"
@.str.7 = [6 x i8] c"float\00"
define i8** @write_array_type(i32 %0, i32 %1, [500 x i8]* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca [500 x i8]*
%7 = alloca i8**
%8 = alloca [500 x i8]
%9 = alloca [500 x i8]
%10 = alloca [500 x i8]
%11 = alloca [500 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store [500 x i8]* %2, [500 x i8]** %6
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8**
store i8** %17, i8*** %7
%18 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds [500 x i8], [500 x i8]* %10, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = getelementptr inbounds [500 x i8], [500 x i8]* %11, i64 0, i64 0
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %26
26: ; preds = %87, %3
%27 = load i32, i32* %5
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %90
30: ; preds = %26
%31 = load [500 x i8]*, [500 x i8]** %6
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [500 x i8], [500 x i8]* %31, i64 %33
%35 = getelementptr inbounds [500 x i8], [500 x i8]* %34, i64 0, i64 0
%36 = getelementptr inbounds [500 x i8], [500 x i8]* %11, i64 0, i64 0
%37 = call i64 @strcmp(i8* %35, i8* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %30
%40 = load i8**, i8*** %7
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %43
br label %44
44: ; preds = %39, %30
%45 = load [500 x i8]*, [500 x i8]** %6
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [500 x i8], [500 x i8]* %45, i64 %47
%49 = getelementptr inbounds [500 x i8], [500 x i8]* %48, i64 0, i64 0
%50 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%51 = call i64 @strcmp(i8* %49, i8* %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %44
%54 = load i8**, i8*** %7
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %57
br label %58
58: ; preds = %53, %44
%59 = load [500 x i8]*, [500 x i8]** %6
%60 = load i32, i32* %5
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [500 x i8], [500 x i8]* %59, i64 %61
%63 = getelementptr inbounds [500 x i8], [500 x i8]* %62, i64 0, i64 0
%64 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%65 = call i64 @strcmp(i8* %63, i8* %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %58
%68 = load i8**, i8*** %7
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %71
br label %72
72: ; preds = %67, %58
%73 = load [500 x i8]*, [500 x i8]** %6
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [500 x i8], [500 x i8]* %73, i64 %75
%77 = getelementptr inbounds [500 x i8], [500 x i8]* %76, i64 0, i64 0
%78 = getelementptr inbounds [500 x i8], [500 x i8]* %10, i64 0, i64 0
%79 = call i64 @strcmp(i8* %77, i8* %78)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %86
81: ; preds = %72
%82 = load i8**, i8*** %7
%83 = load i32, i32* %5
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8*, i8** %82, i64 %84
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %85
br label %86
86: ; preds = %81, %72
br label %87
87: ; preds = %86
%88 = load i32, i32* %5
%89 = add nsw i32 %88, 1
store i32 %89, i32* %5
br label %26
90: ; preds = %26
%91 = load i8**, i8*** %7
ret i8** %91
}

LLVM IR (-O2):
@.str = [4 x i8] c"INT\00"
@.str.1 = [8 x i8] c"VARCHAR\00"
@.str.2 = [6 x i8] c"FLOAT\00"
@.str.3 = [6 x i8] c"TABLE\00"
@.str.4 = [6 x i8] c"table\00"
@.str.5 = [4 x i8] c"int\00"
@.str.6 = [7 x i8] c"String\00"
@.str.7 = [6 x i8] c"float\00"
define i8** @write_array_type(i32 %0, i32 %1, [500 x i8]* %2) {
%4 = alloca [500 x i8]
%5 = alloca [500 x i8]
%6 = alloca [500 x i8]
%7 = alloca [500 x i8]
%8 = shl i32 %0, 3
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8**
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%15 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp sgt i32 %0, 0
br i1 %19, label %20, label %47
20: ; preds = %3
%21 = zext i32 %0 to i64
br label %22
22: ; preds = %20, %44
%23 = phi i64 [ 0, %20 ], [ %45, %44 ]
%24 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 %23, i64 0
%25 = call i64 @strcmp(i8* %24, i8* %14)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = getelementptr inbounds i8*, i8** %10, i64 %23
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %28
br label %29
29: ; preds = %27, %22
%30 = call i64 @strcmp(i8* %24, i8* %11)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = getelementptr inbounds i8*, i8** %10, i64 %23
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %33
br label %34
34: ; preds = %32, %29
%35 = call i64 @strcmp(i8* %24, i8* %12)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = getelementptr inbounds i8*, i8** %10, i64 %23
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %38
br label %39
39: ; preds = %37, %34
%40 = call i64 @strcmp(i8* %24, i8* %13)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = getelementptr inbounds i8*, i8** %10, i64 %23
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %43
br label %44
44: ; preds = %39, %42
%45 = add nuw nsw i64 %23, 1
%46 = icmp eq i64 %45, %21
br i1 %46, label %47, label %22
47: ; preds = %44, %3
ret i8** %10
}