#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char buf[128];
  size_t i;
  for (i = 0; i < 100; ++i) {
    memset(buf, 'x', sizeof(buf));
    strcpy(buf + i, "fnord");
    assert(!strcmp(buf + i, "fnord"));
    assert(buf[i + 6] == 'x');
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x98(%rbp)
cmpq   $0x64,-0x98(%rbp)
64
jae    11fd <main+0xbd>
lea    -0x90(%rbp),%rdi
mov    $0x78,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    -0x90(%rbp),%rdi
add    -0x98(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
add    -0x98(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x98(%rbp),%rax
movsbl -0x8a(%rbp,%rax,1),%eax
ff
cmp    $0x78,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x98(%rbp)
jmp    115d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0xea6(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x78,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    (%rsp,%rbx,1),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x78,0x6(%rsp,%rbx,1)
sete   %dil
call   1060 <assert@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1160 <main+0x20>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"fnord\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %18, %3 ]
%5 = call i32 @memset(i8* %2, i8 signext 120, i32 128)
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %4
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcmp(i8* %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = add nuw nsw i64 %4, 6
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 120
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = add nuw nsw i64 %4, 1
%19 = icmp eq i64 %18, 100
br i1 %19, label %20, label %3
20: ; preds = %3
ret i32 0
}