#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*/ assert(int);
int fmt_str(char *, char *);
int fmt_strm_internal(char *, char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int main() {
  char buf[100];
  buf[5] = 'x';
  assert(fmt_str(buf, "fnord") == 5);
  assert(buf[5] == 'x');
  buf[5] = 0;
  assert(!strcmp(buf, "fnord"));
  assert(fmt_strm_internal(buf, "Fn", "0rd", (char *)0) == 5);
  assert(!strcmp(buf, "Fn0rd"));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movb   $0x78,-0x6b(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fmt_str@plt>
cmp    $0x5,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsbl -0x6b(%rbp),%eax
cmp    $0x78,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movb   $0x0,-0x6b(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x70(%rbp),%rdi
lea    0xe55(%rip),%rsi
lea    0xe53(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <fmt_strm_internal@plt>
cmp    $0x5,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x70(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
movb   $0x78,0x5(%rsp)
lea    0xebf(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <fmt_str@plt>
xor    %edi,%edi
cmp    $0x5,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpb   $0x78,0x5(%rsp)
sete   %dil
call   1040 <assert@plt>
movb   $0x0,0x5(%rsp)
mov    $0x726f6e66,%eax
xor    (%rsp),%eax
movzwl 0x4(%rsp),%ecx
xor    $0x64,%ecx
xor    %edi,%edi
or     %eax,%ecx
sete   %dil
call   1040 <assert@plt>
lea    0xe73(%rip),%rsi
lea    0xe71(%rip),%rdx
mov    %rbx,%rdi
xor    %ecx,%ecx
call   1030 <fmt_strm_internal@plt>
xor    %edi,%edi
cmp    $0x5,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x72306e46,%eax
xor    (%rsp),%eax
movzwl 0x4(%rsp),%ecx
xor    $0x64,%ecx
xor    %edi,%edi
or     %eax,%ecx
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"fnord\00"
@.str.1 = [3 x i8] c"Fn\00"
@.str.2 = [4 x i8] c"0rd\00"
@.str.3 = [6 x i8] c"Fn0rd\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 5
store i8 120, i8* %2
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 @fmt_str(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 5
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 120
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 5
store i8 0, i8* %14
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%22 = call i32 @fmt_strm_internal(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* null)
%23 = icmp eq i32 %22, 5
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"fnord\00"
@.str.1 = [3 x i8] c"Fn\00"
@.str.2 = [4 x i8] c"0rd\00"
@.str.3 = [6 x i8] c"Fn0rd\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 5
store i8 120, i8* %3
%4 = call i32 @fmt_str(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 5
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 120
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store i8 0, i8* %3
%12 = call i32 @bcmp(i8* dereferenceable(6) %2, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 6)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @fmt_strm_internal(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* null)
%17 = icmp eq i32 %16, 5
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 @bcmp(i8* dereferenceable(6) %2, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 6)
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret i32 0
}