#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 */
char *getenv(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char *ptr;
  ptr = getenv(argv[1]);
  ptr += (strlen(argv[0]) - strlen(argv[2])) * 2;
  printf("%s will be at %p\n", argv[1], ptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%ecx
sub    %eax,%ecx
shl    $0x1,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe64(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
mov    (%rbx),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
add    %ebp,%ebp
movslq %ebp,%rdx
add    %r14,%rdx
mov    0x8(%rbx),%rsi
lea    0xe95(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%s will be at %p\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i8* @getenv(i8* %9)
store i8* %10, i8** %6
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @strlen(i8* %13)
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = sub nsw i32 %14, %18
%20 = mul nsw i32 %19, 2
%21 = load i8*, i8** %6
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8* %23, i8** %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i8*, i8** %6
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s will be at %p\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i8* @getenv(i8* %4)
%6 = load i8*, i8** %1
%7 = tail call i32 @strlen(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = sub nsw i32 %7, %10
%12 = shl nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %5, i64 %13
%15 = load i8*, i8** %3
%16 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %14)
ret i32 0
}