#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*/ printf(char *, char *);
int strlen(char *);
int main(void) {
  char str[30] = "look this file!";
  char *ptr;
  ptr = str + strlen(str);
  *ptr++ = '/';
  *ptr = 0;
  printf("str=%s\n", str);
  printf("ptr=%s\n", ptr - 10);
  ptr[-1] = 0;
  printf("str=%s\n", str);
  printf("ptr=%s\n", ptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xebc(%rip),%ax
mov    %ax,-0x14(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x2f,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x30(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
add    $0xfffffffffffffff6,%rsi
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
movb   $0x0,-0x1(%rax)
lea    -0x30(%rbp),%rsi
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movups 0xeda(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
lea    (%rsp,%rbx,1),%r13
add    $0x1,%r13
movw   $0x2f,(%rsp,%rbx,1)
lea    0xeb7(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    (%rsp,%rbx,1),%rsi
add    $0xfffffffffffffff7,%rsi
lea    0xea5(%rip),%r12
mov    %r12,%rdi
call   1040 <printf@plt>
movb   $0x0,(%rsp,%rbx,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str = [30 x i8] c"look this file!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"str=%s\0A\00"
@.str.1 = [8 x i8] c"ptr=%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [30 x i8]* %2 to i8*
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
store i8 47, i8* %10
%12 = load i8*, i8** %3
store i8 0, i8* %12
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 -10
%17 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 -1
store i8 0, i8* %19
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %3
%23 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %22)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [30 x i8] c"look this file!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"str=%s\0A\00"
@.str.1 = [8 x i8] c"ptr=%s\0A\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %4
%6 = getelementptr inbounds i8, i8* %5, i64 1
store i8 47, i8* %5
store i8 0, i8* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %2)
%8 = getelementptr inbounds i8, i8* %5, i64 -9
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %8)
store i8 0, i8* %5
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %6)
ret i32 0
}