#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*/ errx(int, char *, char);
int /*<<< orphan*/ odadd(char *);
char *odformatfp(char, char const *);
char *odformatint(char, char const *);
void odformat(const char *fmt) {
  char fchar;
  while (*fmt != '\0') {
    switch ((fchar = *fmt++)) {
    case 'a':
      odadd("16/1 \"%3_u \" \"\\n\"");
      break;
    case 'c':
      odadd("16/1 \"%3_c \" \"\\n\"");
      break;
    case 'o':
    case 'u':
    case 'd':
    case 'x':
      fmt = odformatint(fchar, fmt);
      break;
    case 'f':
      fmt = odformatfp(fchar, fmt);
      break;
    default:
      errx(1, "%c: unrecognised format character", fchar);
    }
  }
}


x86 assembly (clang, -O0):
<odformat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1205 <odformat+0xc5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %al,%cl
mov    %cl,-0x9(%rbp)
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x17,%eax
ja     11eb <odformat+0xab>
mov    -0x18(%rbp),%rax
lea    0xe70(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec0(%rip),%rdi
call   1050 <odadd@plt>
jmp    1200 <odformat+0xc0>
lea    0xec1(%rip),%rdi
call   1050 <odadd@plt>
jmp    1200 <odformat+0xc0>
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1060 <odformatint@plt>
mov    %rax,-0x8(%rbp)
jmp    1200 <odformat+0xc0>
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <odformatfp@plt>
mov    %rax,-0x8(%rbp)
jmp    1200 <odformat+0xc0>
mov    $0x1,%edi
lea    0xe8d(%rip),%rsi
movsbl -0x9(%rbp),%edx
call   1040 <errx@plt>
jmp    114c <odformat+0xc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<odformat>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     11e2 <odformat+0xa2>
mov    %rdi,%rbx
lea    0xf27(%rip),%r14
lea    0xe9c(%rip),%r13
lea    0xef5(%rip),%r15
lea    0xf00(%rip),%r12
jmp    1197 <odformat+0x57>
mov    $0x1,%edi
mov    %r14,%rsi
call   1040 <errx@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %al,%al
je     11e2 <odformat+0xa2>
movsbl %al,%edx
add    $0x1,%rbx
lea    -0x61(%rdx),%eax
cmp    $0x17,%eax
ja     1174 <odformat+0x34>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    %edx,%edi
mov    %rbx,%rsi
call   1060 <odformatint@plt>
mov    %rax,%rbx
jmp    1190 <odformat+0x50>
mov    %r15,%rdi
call   1050 <odadd@plt>
jmp    1190 <odformat+0x50>
mov    %r12,%rdi
call   1050 <odadd@plt>
jmp    1190 <odformat+0x50>
mov    %edx,%edi
mov    %rbx,%rsi
call   1030 <odformatfp@plt>
mov    %rax,%rbx
jmp    1190 <odformat+0x50>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"16/1 \22%3_u \22 \22\\n\22\00"
@.str.1 = [18 x i8] c"16/1 \22%3_c \22 \22\\n\22\00"
@.str.2 = [34 x i8] c"%c: unrecognised format character\00"
define void @odformat(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
br label %4
4: ; preds = %29, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %30
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %2
%12 = load i8, i8* %10
store i8 %12, i8* %3
%13 = sext i8 %12 to i32
switch i32 %13, label %26 [
i32 97, label %14
i32 99, label %16
i32 111, label %18
i32 117, label %18
i32 100, label %18
i32 120, label %18
i32 102, label %22
]
14: ; preds = %9
%15 = call i32 @odadd(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %29
16: ; preds = %9
%17 = call i32 @odadd(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %29
18: ; preds = %9, %9, %9, %9
%19 = load i8, i8* %3
%20 = load i8*, i8** %2
%21 = call i8* @odformatint(i8 signext %19, i8* %20)
store i8* %21, i8** %2
br label %29
22: ; preds = %9
%23 = load i8, i8* %3
%24 = load i8*, i8** %2
%25 = call i8* @odformatfp(i8 signext %23, i8* %24)
store i8* %25, i8** %2
br label %29
26: ; preds = %9
%27 = load i8, i8* %3
%28 = call i32 @errx(i32 1, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8 signext %27)
br label %29
29: ; preds = %26, %22, %18, %16, %14
br label %4
30: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"16/1 \22%3_u \22 \22\\n\22\00"
@.str.1 = [18 x i8] c"16/1 \22%3_c \22 \22\\n\22\00"
@.str.2 = [34 x i8] c"%c: unrecognised format character\00"
define void @odformat(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1, %19
%5 = phi i8 [ %21, %19 ], [ %2, %1 ]
%6 = phi i8* [ %20, %19 ], [ %0, %1 ]
%7 = sext i8 %5 to i32
%8 = getelementptr inbounds i8, i8* %6, i64 1
switch i32 %7, label %17 [
i32 97, label %9
i32 99, label %11
i32 111, label %13
i32 117, label %13
i32 100, label %13
i32 120, label %13
i32 102, label %15
]
9: ; preds = %4
%10 = tail call i32 @odadd(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %19
11: ; preds = %4
%12 = tail call i32 @odadd(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %19
13: ; preds = %4, %4, %4, %4
%14 = tail call i8* @odformatint(i8 signext %5, i8* %8)
br label %19
15: ; preds = %4
%16 = tail call i8* @odformatfp(i8 signext %5, i8* %8)
br label %19
17: ; preds = %4
%18 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8 signext %5)
br label %19
19: ; preds = %17, %15, %13, %11, %9
%20 = phi i8* [ %8, %17 ], [ %16, %15 ], [ %14, %13 ], [ %8, %11 ], [ %8, %9 ]
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %4
23: ; preds = %19, %1
ret void
}