#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 get_lang_id();
int /*<<< orphan*/ unsupported();
char *enough_type(short *p, int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (p[i] > 0x7f)
      return "short";
  }
  switch (get_lang_id()) {
  case 0:
  case 1:
    return "char";
  case 2:
    return "byte";
  default:
    unsupported();
  }
}


x86 assembly (clang, -O0):
<enough_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117a <enough_type+0x5a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cmp    $0x7f,%eax
jle    1167 <enough_type+0x47>
lea    0xea2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <enough_type+0xac>
jmp    116c <enough_type+0x4c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1136 <enough_type+0x16>
xor    %eax,%eax
call   1040 <get_lang_id@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
sub    $0x2,%eax
jb     11a5 <enough_type+0x85>
jmp    1194 <enough_type+0x74>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     11b5 <enough_type+0x95>
jmp    11c5 <enough_type+0xa5>
lea    0xe5a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <enough_type+0xac>
lea    0xe4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <enough_type+0xac>
mov    $0x0,%al
call   1030 <unsupported@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enough_type>:
push   %rax
test   %esi,%esi
jle    1140 <enough_type+0x20>
mov    %esi,%ecx
xor    %edx,%edx
lea    0xed0(%rip),%rax
cmpw   $0x7f,(%rdi,%rdx,2)
jg     115c <enough_type+0x3c>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1130 <enough_type+0x10>
xor    %eax,%eax
call   1040 <get_lang_id@plt>
cmp    $0x3,%eax
jae    115e <enough_type+0x3e>
cltq
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <unsupported@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"short\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [5 x i8] c"byte\00"
define i8* @enough_type(i16* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i16*
%5 = alloca i32
%6 = alloca i32
store i16* %0, i16** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %21, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i16*, i16** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i16, i16* %12, i64 %14
%16 = load i16, i16* %15
%17 = sext i16 %16 to i32
%18 = icmp sgt i32 %17, 127
br i1 %18, label %19, label %20
19: ; preds = %11
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %3
br label %30
20: ; preds = %11
br label %21
21: ; preds = %20
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %7
24: ; preds = %7
%25 = call i32 (...) @get_lang_id()
switch i32 %25, label %28 [
i32 0, label %26
i32 1, label %26
i32 2, label %27
]
26: ; preds = %24, %24
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %30
27: ; preds = %24
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %30
28: ; preds = %24
%29 = call i32 (...) @unsupported()
br label %30
30: ; preds = %19, %26, %27, %28
%31 = load i8*, i8** %3
ret i8* %31
}

LLVM IR (-O2):
@.str = [6 x i8] c"short\00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [5 x i8] c"byte\00"
@reltable.enough_type = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.enough_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.enough_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.enough_type to i64)) to i32)]
define i8* @enough_type(i16* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %8
6: ; preds = %8
%7 = icmp eq i64 %13, %5
br i1 %7, label %14, label %8
8: ; preds = %4, %6
%9 = phi i64 [ 0, %4 ], [ %13, %6 ]
%10 = getelementptr inbounds i16, i16* %0, i64 %9
%11 = load i16, i16* %10
%12 = icmp sgt i16 %11, 127
%13 = add nuw nsw i64 %9, 1
br i1 %12, label %23, label %6
14: ; preds = %6, %2
%15 = tail call i32 (...) @get_lang_id()
%16 = icmp ult i32 %15, 3
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 (...) @unsupported()
br label %23
19: ; preds = %14
%20 = sext i32 %15 to i64
%21 = shl i64 %20, 2
%22 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.enough_type to i8*), i64 %21)
br label %23
23: ; preds = %8, %19, %17
%24 = phi i8* [ undef, %17 ], [ %22, %19 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %8 ]
ret i8* %24
}