#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *popen(char *, char *);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
unsigned long objdump_address() {
  FILE *command = popen("objdump -d /bin/su|grep '<exit@plt>'|head -n 1|cut -d "
                        "' ' -f 1|sed 's/^[0]*\\([^0]*\\)/0x\\1/'",
                        "r");
  if (!command) {
    perror("[-] popen");
    return 0;
  }
  char result[32];
  fgets(result, 32, command);
  pclose(command);
  return strtoul(result, NULL, 16);
}


x86 assembly (clang, -O0):
<objdump_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
lea    0xef6(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1193 <objdump_address+0x43>
lea    0xedd(%rip),%rdi
call   1060 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    11c4 <objdump_address+0x74>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x20,%esi
call   1040 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1030 <pclose@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1070 <strtoul@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<objdump_address>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xea2(%rip),%rdi
lea    0xef7(%rip),%rsi
call   1050 <popen@plt>
test   %rax,%rax
je     11a4 <objdump_address+0x54>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1030 <pclose@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <strtoul@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeb3(%rip),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
jmp    119c <objdump_address+0x4c>

LLVM IR (-O0):
@.str = [92 x i8] c"objdump -d /bin/su|grep '<exit@plt>'|head -n 1|cut -d ' ' -f 1|sed 's/^[0]*\\([^0]*\\)/0x\\1/'\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"[-] popen\00"
define i64 @objdump_address() {
%1 = alloca i64
%2 = alloca i32*
%3 = alloca [32 x i8]
%4 = call i32* @popen(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %1
br label %17
9: ; preds = %0
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%11 = load i32*, i32** %2
%12 = call i32 @fgets(i8* %10, i32 32, i32* %11)
%13 = load i32*, i32** %2
%14 = call i32 @pclose(i32* %13)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%16 = call i64 @strtoul(i8* %15, i32* null, i32 16)
store i64 %16, i64* %1
br label %17
17: ; preds = %9, %7
%18 = load i64, i64* %1
ret i64 %18
}

LLVM IR (-O2):
@.str = [92 x i8] c"objdump -d /bin/su|grep '<exit@plt>'|head -n 1|cut -d ' ' -f 1|sed 's/^[0]*\\([^0]*\\)/0x\\1/'\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"[-] popen\00"
define i64 @objdump_address() {
%1 = alloca [32 x i8]
%2 = tail call i32* @popen(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %11
6: ; preds = %0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%8 = call i32 @fgets(i8* %7, i32 32, i32* %2)
%9 = call i32 @pclose(i32* %2)
%10 = call i64 @strtoul(i8* nocapture %7, i32* null, i32 16)
br label %11
11: ; preds = %6, %4
%12 = phi i64 [ %10, %6 ], [ 0, %4 ]
ret i64 %12
}