#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 */
struct FB {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fb_bits(struct FB *);
int /*<<< orphan*/ fb_bpp(struct FB *);
struct FB *fb_create(int);
int /*<<< orphan*/ fb_destory(struct FB *);
int /*<<< orphan*/ fb_height(struct FB *);
int /*<<< orphan*/ fb_width(struct FB *);
int /*<<< orphan*/ save_bmp(char const *, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int screen_shot(const char *path) {
  struct FB *fb = NULL;
  fb = fb_create(1);
  if (fb) {
    save_bmp(path, fb_width(fb), fb_height(fb), fb_bits(fb), fb_bpp(fb));
    fb_destory(fb);
  }
  return 0;
}


x86 assembly (clang, -O0):
<screen_shot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x1,%edi
call   1080 <fb_create@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f0 <screen_shot+0x80>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fb_width@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <fb_height@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fb_bits@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fb_bpp@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    %eax,%r8d
call   1070 <save_bmp@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fb_destory@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen_shot>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    $0x1,%edi
call   1080 <fb_create@plt>
test   %rax,%rax
je     11d0 <screen_shot+0x60>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fb_width@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1090 <fb_height@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1050 <fb_bits@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fb_bpp@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
call   1070 <save_bmp@plt>
mov    %rbx,%rdi
call   1030 <fb_destory@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.FB = type { i32 }
define i32 @screen_shot(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.FB*
store i8* %0, i8** %2
store %struct.FB* null, %struct.FB** %3
%4 = call %struct.FB* @fb_create(i32 1)
store %struct.FB* %4, %struct.FB** %3
%5 = load %struct.FB*, %struct.FB** %3
%6 = icmp ne %struct.FB* %5, null
br i1 %6, label %7, label %20
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = load %struct.FB*, %struct.FB** %3
%10 = call i32 @fb_width(%struct.FB* %9)
%11 = load %struct.FB*, %struct.FB** %3
%12 = call i32 @fb_height(%struct.FB* %11)
%13 = load %struct.FB*, %struct.FB** %3
%14 = call i32 @fb_bits(%struct.FB* %13)
%15 = load %struct.FB*, %struct.FB** %3
%16 = call i32 @fb_bpp(%struct.FB* %15)
%17 = call i32 @save_bmp(i8* %8, i32 %10, i32 %12, i32 %14, i32 %16)
%18 = load %struct.FB*, %struct.FB** %3
%19 = call i32 @fb_destory(%struct.FB* %18)
br label %20
20: ; preds = %7, %1
ret i32 0
}

LLVM IR (-O2):
%struct.FB = type { i32 }
define i32 @screen_shot(i8* %0) {
%2 = tail call %struct.FB* @fb_create(i32 1)
%3 = icmp eq %struct.FB* %2, null
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @fb_width(%struct.FB* %2)
%6 = tail call i32 @fb_height(%struct.FB* %2)
%7 = tail call i32 @fb_bits(%struct.FB* %2)
%8 = tail call i32 @fb_bpp(%struct.FB* %2)
%9 = tail call i32 @save_bmp(i8* %0, i32 %5, i32 %6, i32 %7, i32 %8)
%10 = tail call i32 @fb_destory(%struct.FB* %2)
br label %11
11: ; preds = %4, %1
ret i32 0
}