#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 max(int *);
int min(int *);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
int type(char);
char *whattype(char *str) {
  int len = strlen(str);
  int types[len];
  int i = 0;
  while (*str != '\0') {
    types[i] = type(*str);
    printf("Types[i]: %d \n", types[i]);
    i++;
    str++;
  }
  if ((types[0] == 1) && max(types) == 2)
    return "kw_colname";
  else if ((min(types) == 2) && (max(types) == 2))
    return "integer";
  else
    return "other";
}


x86 assembly (clang, -O0):
<whattype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ec <whattype+0x9c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <type@plt>
mov    %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe33(%rip),%rdi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1196 <whattype+0x46>
mov    -0x38(%rbp),%rax
cmpl   $0x1,(%rax)
jne    1222 <whattype+0xd2>
mov    -0x38(%rbp),%rdi
call   1070 <max@plt>
cmp    $0x2,%eax
jne    1222 <whattype+0xd2>
lea    0xdfd(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    126f <whattype+0x11f>
mov    -0x38(%rbp),%rdi
call   1060 <min@plt>
cmp    $0x2,%eax
jne    125d <whattype+0x10d>
mov    -0x38(%rbp),%rdi
call   1070 <max@plt>
cmp    $0x2,%eax
jne    125d <whattype+0x10d>
lea    0xdcd(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    126f <whattype+0x11f>
lea    0xdbe(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whattype>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    (%r14),%al
test   %al,%al
je     11bb <whattype+0x6b>
xor    %ebx,%ebx
lea    0xe76(%rip),%r15
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <type@plt>
mov    %eax,(%r12,%rbx,4)
mov    %r15,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <whattype+0x40>
cmpl   $0x1,(%r12)
jne    11d1 <whattype+0x81>
mov    %r12,%rdi
call   1070 <max@plt>
cmp    $0x2,%eax
jne    11d1 <whattype+0x81>
lea    0xe40(%rip),%rax
jmp    11fb <whattype+0xab>
mov    %r12,%rdi
call   1060 <min@plt>
cmp    $0x2,%eax
jne    11f4 <whattype+0xa4>
mov    %r12,%rdi
call   1070 <max@plt>
cmp    $0x2,%eax
jne    11f4 <whattype+0xa4>
lea    0xe28(%rip),%rax
jmp    11fb <whattype+0xab>
lea    0xe27(%rip),%rax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Types[i]: %d \0A\00"
@.str.1 = [11 x i8] c"kw_colname\00"
@.str.2 = [8 x i8] c"integer\00"
@.str.3 = [6 x i8] c"other\00"
define i8* @whattype(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i32, i64 %12
store i64 %12, i64* %6
store i32 0, i32* %7
br label %15
15: ; preds = %20, %1
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %36
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = call i32 @type(i8 signext %22)
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %14, i64 %25
store i32 %23, i32* %26
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %14, i64 %28
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
br label %15
36: ; preds = %15
%37 = getelementptr inbounds i32, i32* %14, i64 0
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = call i32 @max(i32* %14)
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %44
43: ; preds = %40
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i32 1, i32* %8
br label %52
44: ; preds = %40, %36
%45 = call i32 @min(i32* %14)
%46 = icmp eq i32 %45, 2
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = call i32 @max(i32* %14)
%49 = icmp eq i32 %48, 2
br i1 %49, label %50, label %51
50: ; preds = %47
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
store i32 1, i32* %8
br label %52
51: ; preds = %47, %44
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
store i32 1, i32* %8
br label %52
52: ; preds = %51, %50, %43
%53 = load i8*, i8** %5
%54 = load i8*, i8** %2
ret i8* %54
}

LLVM IR (-O2):
@.str = [15 x i8] c"Types[i]: %d \0A\00"
@.str.1 = [11 x i8] c"kw_colname\00"
@.str.2 = [8 x i8] c"integer\00"
@.str.3 = [6 x i8] c"other\00"
define i8* @whattype(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
%4 = alloca i32, i64 %3
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %14, %7 ], [ 0, %1 ]
%9 = phi i8 [ %16, %7 ], [ %5, %1 ]
%10 = phi i8* [ %15, %7 ], [ %0, %1 ]
%11 = tail call i32 @type(i8 signext %9)
%12 = getelementptr inbounds i32, i32* %4, i64 %8
store i32 %11, i32* %12
%13 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %11)
%14 = add nuw i64 %8, 1
%15 = getelementptr inbounds i8, i8* %10, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %7
18: ; preds = %7
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %1, %18
%22 = call i32 @max(i32* %4)
%23 = icmp eq i32 %22, 2
br i1 %23, label %31, label %24
24: ; preds = %21, %18
%25 = call i32 @min(i32* %4)
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @max(i32* %4)
%29 = icmp eq i32 %28, 2
br i1 %29, label %31, label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %27, %21, %30
%32 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %30 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %21 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %27 ]
ret i8* %32
}