#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 /*<<< orphan*/ f(char *, char *);
int strlen(char *);
int main() {
  char a[100], b[100], *p;
  f(a, "asd");
  assert(strlen(a) == 3);
  a[2] = 0;
  assert(strlen(a) == 2);
  f(b, a);
  assert(strlen(b) == 2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
lea    -0x70(%rbp),%rdi
lea    0xeba(%rip),%rsi
call   1040 <f@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movb   $0x0,-0x6e(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <f@plt>
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xebf(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <f@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1050 <assert@plt>
movb   $0x0,0x2(%rsp)
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <f@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"asd\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = call i32 @f(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = icmp eq i32 %7, 3
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 2
store i8 0, i8* %11
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = icmp eq i32 %13, 2
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%19 = call i32 @f(i8* %17, i8* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = icmp eq i32 %21, 2
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"asd\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @f(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strlen(i8* %3)
%7 = icmp eq i32 %6, 3
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 2
store i8 0, i8* %10
%11 = call i32 @strlen(i8* %3)
%12 = icmp eq i32 %11, 2
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @f(i8* %4, i8* %3)
%16 = call i32 @strlen(i8* %4)
%17 = icmp eq i32 %16, 2
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
ret i32 0
}