#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;
  printf("Foo: %s \n", foo);
  printf("Bar: %s \n", bar);
  printf("Baz: %s \n", baz);
  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    -0x18(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe85(%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>
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"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i8* @ptr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %7)
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %3
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 6
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 -2
store i8* %12, i8** %5
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %5
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %17)
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"
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))
ret i32 0
}