#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 uint32_t;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, void *, ...);
int main(int argc, char *argv[]) {
  const char *test = "test string";
  const char *p;
  uint32_t uidx = 2;
  int32_t sidx = 2;
  printf("uidx == %ld (uint32_t), idx == %ld (int32t)\n", (long)uidx,
         (long)sidx);
  p = test;
  printf("test -> %p\n", (void *)p);
  p = &test[uidx + 1];
  printf("&test[uidx + 1] -> %p\n", (void *)p);
  p = &test[sidx + 1];
  printf("&test[sidx + 1] -> %p\n", (void *)p);
  p = &test[uidx - 3];
  printf("&test[uidx - 3] -> %p\n", (void *)p);
  p = &test[sidx - 3];
  printf("&test[sidx - 3] -> %p\n", (void *)p);
  p = test + uidx - 3;
  printf("test + uidx - 3 -> %p\n", (void *)p);
  p = test + sidx - 3;
  printf("test + sidx - 3 -> %p\n", (void *)p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
movslq -0x24(%rbp),%rsi
movslq -0x28(%rbp),%rdx
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffd,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffd,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xef4(%rip),%rdi
mov    $0x2,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
lea    0xec9(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
lea    0xeb7(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
lea    0xe8a(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"test string\00"
@.str.1 = [45 x i8] c"uidx == %ld (uint32_t), idx == %ld (int32t)\0A\00"
@.str.2 = [12 x i8] c"test -> %p\0A\00"
@.str.3 = [23 x i8] c"&test[uidx + 1] -> %p\0A\00"
@.str.4 = [23 x i8] c"&test[sidx + 1] -> %p\0A\00"
@.str.5 = [23 x i8] c"&test[uidx - 3] -> %p\0A\00"
@.str.6 = [23 x i8] c"&test[sidx - 3] -> %p\0A\00"
@.str.7 = [23 x i8] c"test + uidx - 3 -> %p\0A\00"
@.str.8 = [23 x i8] c"test + sidx - 3 -> %p\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 2, i32* %8
store i32 2, i32* %9
%10 = load i32, i32* %8
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
%13 = load i32, i32* %9
%14 = sext i32 %13 to i64
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %12, i64 %14)
%16 = load i8*, i8** %6
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %6
%20 = load i32, i32* %8
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %6
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %6
%34 = load i32, i32* %8
%35 = sub nsw i32 %34, 3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
store i8* %37, i8** %7
%38 = load i8*, i8** %7
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %6
%41 = load i32, i32* %9
%42 = sub nsw i32 %41, 3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
store i8* %44, i8** %7
%45 = load i8*, i8** %7
%46 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %6
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = getelementptr inbounds i8, i8* %50, i64 -3
store i8* %51, i8** %7
%52 = load i8*, i8** %7
%53 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %52)
%54 = load i8*, i8** %6
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = getelementptr inbounds i8, i8* %57, i64 -3
store i8* %58, i8** %7
%59 = load i8*, i8** %7
%60 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"test string\00"
@.str.1 = [45 x i8] c"uidx == %ld (uint32_t), idx == %ld (int32t)\0A\00"
@.str.2 = [12 x i8] c"test -> %p\0A\00"
@.str.3 = [23 x i8] c"&test[uidx + 1] -> %p\0A\00"
@.str.4 = [23 x i8] c"&test[sidx + 1] -> %p\0A\00"
@.str.5 = [23 x i8] c"&test[uidx - 3] -> %p\0A\00"
@.str.6 = [23 x i8] c"&test[sidx - 3] -> %p\0A\00"
@.str.7 = [23 x i8] c"test + uidx - 3 -> %p\0A\00"
@.str.8 = [23 x i8] c"test + sidx - 3 -> %p\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 2 to i8*), i64 2)
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 3))
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 3))
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 -1, i64 11))
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 -1, i64 11))
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 -1, i64 11))
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 -1, i64 11))
ret i32 0
}