#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*/ putchar(char);
int /*<<< orphan*/ puts(char *);
void printf(char *cformat_str, ...) {
  char *arg;
  char c;
  arg = (char *)(&cformat_str - 1);
  while ((c = *cformat_str++) != '\0') {
    if (c != '%')
      putchar(c);
    else {
      c = *cformat_str++;
      if (c == '%') {
        putchar('%');
      } else if (c == 'c') {
        putchar(*arg--);
      } else if (c == 's') {
        puts(*((char **)arg));
        arg -= sizeof(char *);
      } else if (c == 'd') {
      } else
        return;
    }
  }
}


x86 assembly (clang, -O0):
<printf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     1226 <printf+0x106>
movsbl -0x11(%rbp),%eax
cmp    $0x25,%eax
je     1173 <printf+0x53>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
jmp    1221 <printf+0x101>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x25,%eax
jne    11a3 <printf+0x83>
mov    $0x25,%edi
call   1030 <putchar@plt>
jmp    121c <printf+0xfc>
movsbl -0x11(%rbp),%eax
cmp    $0x63,%eax
jne    11cc <printf+0xac>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    1217 <printf+0xf7>
movsbl -0x11(%rbp),%eax
cmp    $0x73,%eax
jne    11f6 <printf+0xd6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <puts@plt>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x10(%rbp)
jmp    1212 <printf+0xf2>
movsbl -0x11(%rbp),%eax
cmp    $0x64,%eax
jne    1208 <printf+0xe8>
jmp    120d <printf+0xed>
jmp    1226 <printf+0x106>
jmp    1212 <printf+0xf2>
jmp    1217 <printf+0xf7>
jmp    121c <printf+0xfc>
jmp    1221 <printf+0x101>
jmp    1138 <printf+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    -0x8(%rsp),%r14
nopl   0x0(%rax)
mov    %rbx,%rax
lea    0x1(%rax),%rbx
mov    %rbx,(%rsp)
movzbl (%rax),%ecx
cmp    $0x25,%cl
jne    1170 <printf+0x50>
lea    0x2(%rax),%rbx
mov    %rbx,(%rsp)
movzbl 0x1(%rax),%ecx
cmp    $0x63,%cl
jle    1180 <printf+0x60>
mov    %rbx,%rax
cmp    $0x64,%cl
je     1133 <printf+0x13>
cmp    $0x73,%cl
jne    11a5 <printf+0x85>
mov    (%r14),%rdi
call   1040 <puts@plt>
add    $0xfffffffffffffff8,%r14
jmp    1130 <printf+0x10>
nop
test   %cl,%cl
je     11a5 <printf+0x85>
movsbl %cl,%edi
call   1030 <putchar@plt>
jmp    1130 <printf+0x10>
xchg   %ax,%ax
cmp    $0x25,%cl
jne    1191 <printf+0x71>
mov    $0x25,%edi
call   1030 <putchar@plt>
jmp    1130 <printf+0x10>
cmp    $0x63,%cl
jne    11a5 <printf+0x85>
movsbl (%r14),%edi
add    $0xffffffffffffffff,%r14
call   1030 <putchar@plt>
jmp    1130 <printf+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @printf(i8* %0, ...) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %2
%5 = getelementptr inbounds i8*, i8** %2, i64 -1
%6 = bitcast i8** %5 to i8*
store i8* %6, i8** %3
br label %7
7: ; preds = %59, %1
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %2
%10 = load i8, i8* %8
store i8 %10, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %60
13: ; preds = %7
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 37
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i8, i8* %4
%19 = call i32 @putchar(i8 signext %18)
br label %59
20: ; preds = %13
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %2
%23 = load i8, i8* %21
store i8 %23, i8* %4
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 37
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 @putchar(i8 signext 37)
br label %58
29: ; preds = %20
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 99
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 -1
store i8* %35, i8** %3
%36 = load i8, i8* %34
%37 = call i32 @putchar(i8 signext %36)
br label %57
38: ; preds = %29
%39 = load i8, i8* %4
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 115
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = load i8*, i8** %3
%44 = bitcast i8* %43 to i8**
%45 = load i8*, i8** %44
%46 = call i32 @puts(i8* %45)
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 -8
store i8* %48, i8** %3
br label %56
49: ; preds = %38
%50 = load i8, i8* %4
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 100
br i1 %52, label %53, label %54
53: ; preds = %49
br label %55
54: ; preds = %49
br label %60
55: ; preds = %53
br label %56
56: ; preds = %55, %42
br label %57
57: ; preds = %56, %33
br label %58
58: ; preds = %57, %27
br label %59
59: ; preds = %58, %17
br label %7
60: ; preds = %54, %7
ret void
}

LLVM IR (-O2):
define void @printf(i8* %0, ...) {
%2 = alloca i8*
%3 = getelementptr inbounds i8*, i8** %2, i64 -1
%4 = bitcast i8** %3 to i8*
br label %5
5: ; preds = %25, %1
%6 = phi i8* [ %0, %1 ], [ %15, %25 ]
%7 = phi i8* [ %4, %1 ], [ %26, %25 ]
br label %8
8: ; preds = %17, %5
%9 = phi i8* [ %6, %5 ], [ %18, %17 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %10, i8** %2
%11 = load i8, i8* %9
switch i8 %11, label %12 [
i8 0, label %32
i8 37, label %14
]
12: ; preds = %8
%13 = tail call i32 @putchar(i8 signext %11)
br label %17
14: ; preds = %8
%15 = getelementptr inbounds i8, i8* %9, i64 2
store i8* %15, i8** %2
%16 = load i8, i8* %10
switch i8 %16, label %32 [
i8 37, label %19
i8 99, label %21
i8 115, label %27
i8 100, label %17
]
17: ; preds = %14, %19, %12
%18 = phi i8* [ %10, %12 ], [ %15, %19 ], [ %15, %14 ]
br label %8
19: ; preds = %14
%20 = tail call i32 @putchar(i8 signext 37)
br label %17
21: ; preds = %14
%22 = getelementptr inbounds i8, i8* %7, i64 -1
%23 = load i8, i8* %7
%24 = tail call i32 @putchar(i8 signext %23)
br label %25
25: ; preds = %21, %27
%26 = phi i8* [ %31, %27 ], [ %22, %21 ]
br label %5
27: ; preds = %14
%28 = bitcast i8* %7 to i8**
%29 = load i8*, i8** %28
%30 = tail call i32 @puts(i8* dereferenceable(1) %29)
%31 = getelementptr inbounds i8, i8* %7, i64 -8
br label %25
32: ; preds = %8, %14
ret void
}