#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 char_count(char *, char);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  char msg[] = "Everything should be made as simple as "
               "possible, but not simpler.";
  printf("Number of o's: %d\n", char_count(msg, 'o'));
  printf("Number of NULL characters: %d\n", char_count(msg, '\0'));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x42,%edx
call   1040 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    $0x6f,%esi
call   1050 <char_count@plt>
mov    %eax,%esi
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
call   1050 <char_count@plt>
mov    %eax,%esi
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movaps 0xf04(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x2e,0x40(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x6f,%esi
call   1040 <char_count@plt>
lea    0xed0(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <char_count@plt>
lea    0xecb(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.msg = [66 x i8] c"Everything should be made as simple as possible, but not simpler.\00"
@.str = [19 x i8] c"Number of o's: %d\0A\00"
@.str.1 = [31 x i8] c"Number of NULL characters: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [66 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [66 x i8]* %6 to i8*
%8 = getelementptr inbounds [66 x i8], [66 x i8]* %6, i64 0, i64 0
%9 = call i32 @char_count(i8* %8, i8 signext 111)
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [66 x i8], [66 x i8]* %6, i64 0, i64 0
%12 = call i32 @char_count(i8* %11, i8 signext 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.msg = [66 x i8] c"Everything should be made as simple as possible, but not simpler.\00"
@.str = [19 x i8] c"Number of o's: %d\0A\00"
@.str.1 = [31 x i8] c"Number of NULL characters: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [66 x i8]
%4 = getelementptr inbounds [66 x i8], [66 x i8]* %3, i64 0, i64 0
%5 = call i32 @char_count(i8* %4, i8 signext 111)
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @char_count(i8* %4, i8 signext 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret i32 0
}