#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ stderr;
int read_setun_char(char c) {
  switch (c) {
  case '0':
    return 0;
  case '1':
    return 1;
  case '$':
    return -1;
  default:
    fprintf(stderr, "offending character: '%c'\n", c);
    abort();
  }
}


x86 assembly (clang, -O0):
<read_setun_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x24,%eax
je     117d <read_setun_char+0x5d>
jmp    1143 <read_setun_char+0x23>
mov    -0xc(%rbp),%eax
sub    $0x30,%eax
je     1165 <read_setun_char+0x45>
jmp    1154 <read_setun_char+0x34>
mov    -0xc(%rbp),%eax
sub    $0x31,%eax
je     1171 <read_setun_char+0x51>
jmp    1189 <read_setun_char+0x69>
movl   $0x0,-0x4(%rbp)
jmp    11a9 <read_setun_char+0x89>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <read_setun_char+0x89>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a9 <read_setun_char+0x89>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
movsbl -0x5(%rbp),%edx
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_setun_char>:
cmp    $0x24,%edi
je     1137 <read_setun_char+0x17>
xor    %eax,%eax
cmp    $0x30,%edi
je     113c <read_setun_char+0x1c>
cmp    $0x31,%edi
jne    113d <read_setun_char+0x1d>
mov    $0x1,%eax
ret
mov    $0xffffffff,%eax
ret
push   %rax
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
movsbl %dil,%edx
lea    0xeae(%rip),%rsi
mov    %eax,%edi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"offending character: '%c'\0A\00"
define i32 @read_setun_char(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %9 [
i32 48, label %6
i32 49, label %7
i32 36, label %8
]
6: ; preds = %1
store i32 0, i32* %2
br label %14
7: ; preds = %1
store i32 1, i32* %2
br label %14
8: ; preds = %1
store i32 -1, i32* %2
br label %14
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i8, i8* %3
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %8, %7, %6
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"offending character: '%c'\0A\00"
define i32 @read_setun_char(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %5 [
i32 48, label %9
i32 49, label %3
i32 36, label %4
]
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8 signext %0)
%8 = tail call i32 (...) @abort()
unreachable
9: ; preds = %1, %4, %3
%10 = phi i32 [ -1, %4 ], [ 1, %3 ], [ 0, %1 ]
ret i32 %10
}