#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 const, ...);
int main() {
  const char *string = "0123456789";
  const char *ptr = string + 4;
  printf("-9 %% 4 = %d\n", -9 % 4);
  printf("ptr[0] = '%c' = string[4] = '%c'\n", ptr[0], string[4]);
  printf("ptr[-2] = '%c' = string[2] = '%c'\n", ptr[-2], string[2]);
  return (ptr[-2] - string[2]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
lea    0xece(%rip),%rdi
mov    $0xffffffff,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rcx
movsbl 0x4(%rcx),%edx
lea    0xebb(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x2(%rax),%al
mov    -0x10(%rbp),%rcx
movsbl 0x2(%rcx),%edx
lea    0xebd(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movsbl -0x2(%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x34,%esi
mov    $0x34,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x32,%esi
mov    $0x32,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0123456789\00"
@.str.1 = [14 x i8] c"-9 %% 4 = %d\0A\00"
@.str.2 = [34 x i8] c"ptr[0] = '%c' = string[4] = '%c'\0A\00"
@.str.3 = [35 x i8] c"ptr[-2] = '%c' = string[2] = '%c'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 4
store i8* %5, i8** %3
%6 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8 signext -1)
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8 signext %9, i32 %13)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 -2
%17 = load i8, i8* %16
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8 signext %17, i32 %21)
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 -2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 2
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %26, %30
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"-9 %% 4 = %d\0A\00"
@.str.2 = [34 x i8] c"ptr[0] = '%c' = string[4] = '%c'\0A\00"
@.str.3 = [35 x i8] c"ptr[-2] = '%c' = string[2] = '%c'\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8 signext -1)
%2 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8 signext 52, i32 52)
%3 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8 signext 50, i32 50)
ret i32 0
}