#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 *);
char *ptr(char *, int);
int main() {
  char *test = ptr("obsidian", 3);
  printf("Ptr: %s \n", test);
  char *foo = "obsidian";
  char *bar = foo + 6;
  char *baz = bar - 2;
  char *hello = baz - 4;
  printf("Foo: %s \n", foo);
  printf("Bar: %s \n", bar);
  printf("Baz: %s \n", baz);
  printf("Hello: %s \n", hello);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x3,%esi
call   1040 <ptr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xea5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <ptr@plt>
lea    0xecd(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"obsidian\00"
@.str.1 = [10 x i8] c"Ptr: %s \0A\00"
@.str.2 = [10 x i8] c"Foo: %s \0A\00"
@.str.3 = [10 x i8] c"Bar: %s \0A\00"
@.str.4 = [10 x i8] c"Baz: %s \0A\00"
@.str.5 = [12 x i8] c"Hello: %s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = call i8* @ptr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %8)
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %3
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 6
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 -2
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 -4
store i8* %15, i8** %6
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %5
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %6
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"obsidian\00"
@.str.1 = [10 x i8] c"Ptr: %s \0A\00"
@.str.2 = [10 x i8] c"Foo: %s \0A\00"
@.str.3 = [10 x i8] c"Bar: %s \0A\00"
@.str.4 = [10 x i8] c"Baz: %s \0A\00"
@.str.5 = [12 x i8] c"Hello: %s \0A\00"
define i32 @main() {
%1 = tail call i8* @ptr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 6))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 4))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret i32 0
}