#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 */
typedef int /*<<< orphan*/ classes;

/* Variables and functions */
#define GrayScale 132
#define PseudoColor 131
#define StaticColor 130
#define StaticGray 129
#define TrueColor 128
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
scalar_t__ pgx_same_string(char *, char *);
int /*<<< orphan*/ stderr;
int pgx_parse_visual(char *str) {
  static struct {
    char *name;
    int class;
  } classes[] = {{"monochrome", -2},           {"default", -1},
                 {"pseudocolor", PseudoColor}, {"directcolor", TrueColor},
                 {"staticcolor", StaticColor}, {"truecolor", TrueColor},
                 {"grayscale", GrayScale},     {"staticgray", StaticGray}};
  int i;
  if (str) {
    for (i = 0; i < sizeof(classes) / sizeof(classes[0]); i++) {
      if (pgx_same_string(str, classes[i].name))
        return classes[i].class;
    };
    fprintf(stderr, "%s: Unrecognised visual type: \"%s\".\n", "pgxwin", str);
  };
  return -1;
}


x86 assembly (clang, -O0):
<pgx_parse_visual>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c4 <pgx_parse_visual+0xa4>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x8,%rax
jae    11a4 <pgx_parse_visual+0x84>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2ee5(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
call   1040 <pgx_same_string@plt>
cmp    $0x0,%rax
je     1191 <pgx_parse_visual+0x71>
movslq -0x14(%rbp),%rcx
lea    0x2ec1(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11cb <pgx_parse_visual+0xab>
jmp    1196 <pgx_parse_visual+0x76>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <pgx_parse_visual+0x1e>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
lea    0xe9e(%rip),%rsi
lea    0xebc(%rip),%rdx
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pgx_parse_visual>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     120e <pgx_parse_visual+0xee>
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1040 <pgx_same_string@plt>
test   %rax,%rax
je     114c <pgx_parse_visual+0x2c>
xor    %ecx,%ecx
jmp    11ff <pgx_parse_visual+0xdf>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <pgx_same_string@plt>
mov    $0x1,%ecx
test   %rax,%rax
jne    11ff <pgx_parse_visual+0xdf>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <pgx_same_string@plt>
mov    $0x2,%ecx
test   %rax,%rax
jne    11ff <pgx_parse_visual+0xdf>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1040 <pgx_same_string@plt>
mov    $0x3,%ecx
test   %rax,%rax
jne    11ff <pgx_parse_visual+0xdf>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1040 <pgx_same_string@plt>
mov    $0x4,%ecx
test   %rax,%rax
jne    11ff <pgx_parse_visual+0xdf>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <pgx_same_string@plt>
mov    $0x5,%ecx
test   %rax,%rax
jne    11ff <pgx_parse_visual+0xdf>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <pgx_same_string@plt>
mov    $0x6,%ecx
test   %rax,%rax
jne    11ff <pgx_parse_visual+0xdf>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <pgx_same_string@plt>
mov    $0x7,%ecx
test   %rax,%rax
je     1217 <pgx_parse_visual+0xf7>
shl    $0x4,%rcx
lea    0x2b86(%rip),%rax
mov    0x8(%rcx,%rax,1),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
lea    0xe4d(%rip),%rdx
mov    %rbx,%rcx
call   1030 <fprintf@plt>
jmp    120e <pgx_parse_visual+0xee>

LLVM IR (-O0):
%struct.anon = type { i8*, i32 }
@pgx_parse_visual.classes = internal global [8 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 -2 }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 -1 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0), i32 130 }, %struct.anon { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0), i32 129 }]
@.str = [11 x i8] c"monochrome\00"
@.str.1 = [8 x i8] c"default\00"
@.str.2 = [12 x i8] c"pseudocolor\00"
@.str.3 = [12 x i8] c"directcolor\00"
@.str.4 = [12 x i8] c"staticcolor\00"
@.str.5 = [10 x i8] c"truecolor\00"
@.str.6 = [10 x i8] c"grayscale\00"
@.str.7 = [11 x i8] c"staticgray\00"
@stderr = global i32 0
@.str.8 = [37 x i8] c"%s: Unrecognised visual type: \22%s\22.\0A\00"
@.str.9 = [7 x i8] c"pgxwin\00"
define i32 @pgx_parse_visual(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %35
7: ; preds = %1
store i32 0, i32* %4
br label %8
8: ; preds = %28, %7
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = icmp ult i64 %10, 8
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8 x %struct.anon], [8 x %struct.anon]* @pgx_parse_visual.classes, i64 0, i64 %15
%17 = getelementptr inbounds %struct.anon, %struct.anon* %16, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i64 @pgx_same_string(i8* %13, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %12
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8 x %struct.anon], [8 x %struct.anon]* @pgx_parse_visual.classes, i64 0, i64 %23
%25 = getelementptr inbounds %struct.anon, %struct.anon* %24, i32 0, i32 1
%26 = load i32, i32* %25
store i32 %26, i32* %2
br label %36
27: ; preds = %12
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %8
31: ; preds = %8
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %3
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %31, %1
store i32 -1, i32* %2
br label %36
36: ; preds = %35, %21
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
%struct.anon = type { i8*, i32 }
@pgx_parse_visual.classes = internal unnamed_addr constant [8 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 -2 }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 -1 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0), i32 130 }, %struct.anon { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0), i32 129 }]
@.str = [11 x i8] c"monochrome\00"
@.str.1 = [8 x i8] c"default\00"
@.str.2 = [12 x i8] c"pseudocolor\00"
@.str.3 = [12 x i8] c"directcolor\00"
@.str.4 = [12 x i8] c"staticcolor\00"
@.str.5 = [10 x i8] c"truecolor\00"
@.str.6 = [10 x i8] c"grayscale\00"
@.str.7 = [11 x i8] c"staticgray\00"
@stderr = global i32 0
@.str.8 = [37 x i8] c"%s: Unrecognised visual type: \22%s\22.\0A\00"
@.str.9 = [7 x i8] c"pgxwin\00"
define i32 @pgx_parse_visual(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %34, label %3
3: ; preds = %1
%4 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %28, %25, %22, %19, %16, %13, %10, %3
%7 = phi i64 [ 0, %3 ], [ 1, %10 ], [ 2, %13 ], [ 3, %16 ], [ 4, %19 ], [ 5, %22 ], [ 6, %25 ], [ 7, %28 ]
%8 = getelementptr inbounds [8 x %struct.anon], [8 x %struct.anon]* @pgx_parse_visual.classes, i64 0, i64 %7, i32 1
%9 = load i32, i32* %8
br label %34
10: ; preds = %3
%11 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %6
13: ; preds = %10
%14 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %6
16: ; preds = %13
%17 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %6
19: ; preds = %16
%20 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %6
22: ; preds = %19
%23 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %6
25: ; preds = %22
%26 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %6
28: ; preds = %25
%29 = tail call i64 @pgx_same_string(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %6
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %0)
br label %34
34: ; preds = %1, %31, %6
%35 = phi i32 [ %9, %6 ], [ -1, %31 ], [ -1, %1 ]
ret i32 %35
}