#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*/ mjpeg_error_exit1(char *);
int parse_interlacing(char *str) {
  if (str[0] != '\0' && str[1] == '\0') {
    switch (str[0]) {
    case 'p':
      return 0;
    case 't':
      return 1;
    case 'b':
      return 2;
    }
  }
  mjpeg_error_exit1("Valid interlacing modes are: p - progressive, t - "
                    "top-field first, b - bottom-field first");
  return -1;
}


x86 assembly (clang, -O0):
<parse_interlacing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a0 <parse_interlacing+0x90>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    11a0 <parse_interlacing+0x90>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x62,%eax
je     118f <parse_interlacing+0x7f>
jmp    1155 <parse_interlacing+0x45>
mov    -0x14(%rbp),%eax
sub    $0x70,%eax
je     1177 <parse_interlacing+0x67>
jmp    1166 <parse_interlacing+0x56>
mov    -0x14(%rbp),%eax
sub    $0x74,%eax
je     1183 <parse_interlacing+0x73>
jmp    119b <parse_interlacing+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <parse_interlacing+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    11b3 <parse_interlacing+0xa3>
movl   $0x2,-0x4(%rbp)
jmp    11b3 <parse_interlacing+0xa3>
jmp    11a0 <parse_interlacing+0x90>
lea    0xe59(%rip),%rdi
call   1030 <mjpeg_error_exit1@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_interlacing>:
push   %rax
movsbl (%rdi),%eax
test   %eax,%eax
je     111e <parse_interlacing+0xe>
cmpb   $0x0,0x1(%rdi)
je     1131 <parse_interlacing+0x21>
lea    0xedb(%rip),%rdi
call   1030 <mjpeg_error_exit1@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
cmp    $0x62,%eax
je     1147 <parse_interlacing+0x37>
cmp    $0x70,%eax
je     114e <parse_interlacing+0x3e>
cmp    $0x74,%eax
jne    111e <parse_interlacing+0xe>
mov    $0x1,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [90 x i8] c"Valid interlacing modes are: p - progressive, t - top-field first, b - bottom-field first\00"
define i32 @parse_interlacing(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %23 [
i32 112, label %20
i32 116, label %21
i32 98, label %22
]
20: ; preds = %15
store i32 0, i32* %2
br label %26
21: ; preds = %15
store i32 1, i32* %2
br label %26
22: ; preds = %15
store i32 2, i32* %2
br label %26
23: ; preds = %15
br label %24
24: ; preds = %23, %9, %1
%25 = call i32 @mjpeg_error_exit1(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %26
26: ; preds = %24, %22, %21, %20
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [90 x i8] c"Valid interlacing modes are: p - progressive, t - top-field first, b - bottom-field first\00"
define i32 @parse_interlacing(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = icmp eq i8 %2, 0
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %5
switch i32 %3, label %12 [
i32 112, label %14
i32 116, label %10
i32 98, label %11
]
10: ; preds = %9
br label %14
11: ; preds = %9
br label %14
12: ; preds = %9, %5, %1
%13 = tail call i32 @mjpeg_error_exit1(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %9, %12, %11, %10
%15 = phi i32 [ -1, %12 ], [ 2, %11 ], [ 1, %10 ], [ 0, %9 ]
ret i32 %15
}