#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*/ free(char *);
char *getErrString(int);
int /*<<< orphan*/ printf(char *, int, char *);
char *strdup(char *);
int /*<<< orphan*/ *strstr(char *, char *);
char tolower(char);
void printmsgs(char *msgs[255 + 1], char *str) {
  int i;
  int c;
  char *strlc;
  strlc = strdup(str);
  c = 0;
  while (strlc[c] != '\0') {
    strlc[c] = tolower(strlc[c]);
    c++;
  }
  for (i = 0; i <= 255; i++) {
    if (strstr(msgs[i], strlc) != NULL)
      printf("%d:%s\n", i, getErrString(i));
  }
  free(strlc);
  return;
}


x86 assembly (clang, -O0):
<printmsgs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11c5 <printmsgs+0x65>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1184 <printmsgs+0x24>
movl   $0x0,-0x14(%rbp)
cmpl   $0xff,-0x14(%rbp)
jg     122b <printmsgs+0xcb>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1218 <printmsgs+0xb8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <getErrString@plt>
mov    -0x24(%rbp),%esi
mov    %rax,%rdx
lea    0xded(%rip),%rdi
call   1050 <printf@plt>
jmp    121d <printmsgs+0xbd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cc <printmsgs+0x6c>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printmsgs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
call   1070 <strdup@plt>
mov    %rax,%r15
mov    (%rax),%al
test   %al,%al
je     1196 <printmsgs+0x36>
lea    0x1(%r15),%rbx
movsbl %al,%edi
call   1060 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <printmsgs+0x20>
xor    %ebx,%ebx
lea    0xe61(%rip),%r12
jmp    11bd <printmsgs+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     11e4 <printmsgs+0x84>
mov    (%r14,%rbx,8),%rdi
mov    %r15,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     11b0 <printmsgs+0x50>
mov    %ebx,%edi
call   1040 <getErrString@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1050 <printf@plt>
jmp    11b0 <printmsgs+0x50>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d:%s\0A\00"
define void @printmsgs(i8** nocapture %0, i8* nocapture %1) {
%3 = tail call i8* @strdup(i8* %1)
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %2, %6
%7 = phi i64 [ %11, %6 ], [ 0, %2 ]
%8 = phi i8 [ %13, %6 ], [ %4, %2 ]
%9 = phi i8* [ %12, %6 ], [ %3, %2 ]
%10 = tail call signext i8 @tolower(i8 signext %8)
store i8 %10, i8* %9
%11 = add nuw i64 %7, 1
%12 = getelementptr inbounds i8, i8* %3, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %2
br label %16
16: ; preds = %15, %26
%17 = phi i64 [ %27, %26 ], [ 0, %15 ]
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
%20 = tail call i32* @strstr(i8* dereferenceable(1) %19, i8* dereferenceable(1) %3)
%21 = icmp eq i32* %20, null
br i1 %21, label %26, label %22
22: ; preds = %16
%23 = trunc i64 %17 to i32
%24 = tail call i8* @getErrString(i32 %23)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %23, i8* %24)
br label %26
26: ; preds = %16, %22
%27 = add nuw nsw i64 %17, 1
%28 = icmp eq i64 %27, 256
br i1 %28, label %29, label %16
29: ; preds = %26
%30 = tail call i32 @free(i8* %3)
ret void
}