#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*/ ctest1(int *);
int /*<<< orphan*/ dlclose(void *);
int /*<<< orphan*/ fff();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  void *lib_handle;
  void (*pctest1)(int *);
  void (*pfff)(void);
  int x;
  char *error;
  x = 10;
  printf("going to invoke dynamically linked symbol <ctest1>\n");
  ctest1(&x);
  printf("Valx=%d\n", x);
  x = 10;
  printf("going to invoke dynamically linked symbol <fff>\n");
  fff();
  printf("Valx=%d\n", x);
  dlclose(lib_handle);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x2c(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2c(%rbp),%rdi
call   1040 <ctest1@plt>
mov    -0x2c(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0x2c(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <fff@plt>
mov    -0x2c(%rbp),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <dlclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0xa,0xc(%rsp)
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rdi
call   1050 <ctest1@plt>
mov    0xc(%rsp),%esi
lea    0xe82(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0xa,0xc(%rsp)
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <fff@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
call   1060 <dlclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [52 x i8] c"going to invoke dynamically linked symbol <ctest1>\0A\00"
@.str.1 = [9 x i8] c"Valx=%d\0A\00"
@.str.2 = [49 x i8] c"going to invoke dynamically linked symbol <fff>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca void (i32*)*
%8 = alloca void ()*
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @ctest1(i32* %9)
%13 = load i32, i32* %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %13)
store i32 10, i32* %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (...) @fff()
%17 = load i32, i32* %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i8*, i8** %6
%20 = call i32 @dlclose(i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"Valx=%d\0A\00"
@str = [51 x i8] c"going to invoke dynamically linked symbol <ctest1>\00"
@str.3 = [48 x i8] c"going to invoke dynamically linked symbol <fff>\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 10, i32* %3
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%6 = call i32 @ctest1(i32* %3)
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %7)
store i32 10, i32* %3
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.3, i64 0, i64 0))
%10 = call i32 (...) @fff()
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call i32 @dlclose(i8* undef)
ret i32 0
}