#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*/ getErrString(int);
char *strdup(int /*<<< orphan*/);
char tolower(char);
int buildmsgtable(char *msgs[255 + 1]) {
  int i;
  int c;
  for (i = 0; i <= 255; i++) {
    msgs[i] = strdup(getErrString(i));
    c = 0;
    while (msgs[i][c] != '\0') {
      msgs[i][c] = tolower(msgs[i][c]);
      c++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<buildmsgtable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xff,-0xc(%rbp)
jg     11e1 <buildmsgtable+0xb1>
mov    -0xc(%rbp),%edi
call   1030 <getErrString@plt>
mov    %eax,%edi
call   1050 <strdup@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11ce <buildmsgtable+0x9e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1175 <buildmsgtable+0x45>
jmp    11d3 <buildmsgtable+0xa3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <buildmsgtable+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildmsgtable>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %r15d,%r15d
jmp    114d <buildmsgtable+0x1d>
nopl   (%rax)
add    $0x1,%r15
cmp    $0x100,%r15
je     1192 <buildmsgtable+0x62>
mov    %r15d,%edi
call   1030 <getErrString@plt>
mov    %eax,%edi
call   1050 <strdup@plt>
mov    %rax,(%r14,%r15,8)
mov    (%rax),%al
test   %al,%al
je     1140 <buildmsgtable+0x10>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    (%r14,%r15,8),%rcx
mov    %al,(%rcx,%rbx,1)
mov    (%r14,%r15,8),%rax
movzbl 0x1(%rax,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1170 <buildmsgtable+0x40>
jmp    1140 <buildmsgtable+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @buildmsgtable(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
store i8** %0, i8*** %2
store i32 0, i32* %3
br label %5
5: ; preds = %50, %1
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 255
br i1 %7, label %8, label %53
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @getErrString(i32 %9)
%11 = call i8* @strdup(i32 %10)
%12 = load i8**, i8*** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
store i8* %11, i8** %15
store i32 0, i32* %4
br label %16
16: ; preds = %28, %8
%17 = load i8**, i8*** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %49
28: ; preds = %16
%29 = load i8**, i8*** %2
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call signext i8 @tolower(i8 signext %37)
%39 = load i8**, i8*** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 %38, i8* %46
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %16
49: ; preds = %16
br label %50
50: ; preds = %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %5
53: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
define i32 @buildmsgtable(i8** nocapture %0) {
br label %2
2: ; preds = %1, %21
%3 = phi i64 [ 0, %1 ], [ %22, %21 ]
%4 = trunc i64 %3 to i32
%5 = tail call i32 @getErrString(i32 %4)
%6 = tail call i8* @strdup(i32 %5)
%7 = getelementptr inbounds i8*, i8** %0, i64 %3
store i8* %6, i8** %7
%8 = load i8, i8* %6
%9 = icmp eq i8 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %2, %10
%11 = phi i64 [ %16, %10 ], [ 0, %2 ]
%12 = phi i8 [ %19, %10 ], [ %8, %2 ]
%13 = tail call signext i8 @tolower(i8 signext %12)
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 %11
store i8 %13, i8* %15
%16 = add nuw i64 %11, 1
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %10
21: ; preds = %10, %2
%22 = add nuw nsw i64 %3, 1
%23 = icmp eq i64 %22, 256
br i1 %23, label %24, label %2
24: ; preds = %21
ret i32 0
}