#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 */
long long getX_int();
int /*<<< orphan*/ lift();
int /*<<< orphan*/ restore_flags(int const);
int save_flags();
int /*<<< orphan*/ setX_int(long long);
int /*<<< orphan*/ set_reg_n_int(int, long long);
int /*<<< orphan*/ setlastX();
long long stub1(long long);
void justify(long long int (*shift)(long long int), const long long int mask) {
  unsigned int c = 0;
  long long int v;
  v = getX_int();
  setlastX();
  lift();
  if (v != 0) {
    const int flags = save_flags();
    while ((v & mask) == 0) {
      v = (*shift)(v);
      c++;
    }
    restore_flags(flags);
    set_reg_n_int(((100) + 1), v);
  }
  setX_int((long long int)c);
}


x86 assembly (clang, -O0):
<justify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1080 <getX_int@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <setlastX@plt>
mov    $0x0,%al
call   1050 <lift@plt>
cmpq   $0x0,-0x20(%rbp)
je     11f9 <justify+0x89>
mov    $0x0,%al
call   1060 <save_flags@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
and    -0x10(%rbp),%rax
cmp    $0x0,%rax
jne    11e3 <justify+0x73>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rdi
call   *%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b5 <justify+0x45>
mov    -0x24(%rbp),%edi
call   1030 <restore_flags@plt>
mov    -0x20(%rbp),%rsi
mov    $0x65,%edi
call   1090 <set_reg_n_int@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%edi
call   1040 <setX_int@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<justify>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <getX_int@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <setlastX@plt>
xor    %eax,%eax
call   1050 <lift@plt>
test   %rbx,%rbx
je     11d6 <justify+0x66>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <save_flags@plt>
mov    %eax,%r12d
test   %r14,%rbx
jne    11c1 <justify+0x51>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   *%r15
mov    %rax,%rbx
add    $0x1,%ebp
test   %r14,%rax
je     11b0 <justify+0x40>
mov    %r12d,%edi
call   1030 <restore_flags@plt>
mov    $0x65,%edi
mov    %rbx,%rsi
call   1090 <set_reg_n_int@plt>
mov    %ebp,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <setX_int@plt>

LLVM IR (-O0):
define void @justify(i64 (i64)* %0, i64 %1) {
%3 = alloca i64 (i64)*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
store i64 (i64)* %0, i64 (i64)** %3
store i64 %1, i64* %4
store i32 0, i32* %5
%8 = call i64 (...) @getX_int()
store i64 %8, i64* %6
%9 = call i32 (...) @setlastX()
%10 = call i32 (...) @lift()
%11 = load i64, i64* %6
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %31
13: ; preds = %2
%14 = call i32 (...) @save_flags()
store i32 %14, i32* %7
br label %15
15: ; preds = %20, %13
%16 = load i64, i64* %6
%17 = load i64, i64* %4
%18 = and i64 %16, %17
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i64 (i64)*, i64 (i64)** %3
%22 = load i64, i64* %6
%23 = call i64 %21(i64 %22)
store i64 %23, i64* %6
%24 = load i32, i32* %5
%25 = add i32 %24, 1
store i32 %25, i32* %5
br label %15
26: ; preds = %15
%27 = load i32, i32* %7
%28 = call i32 @restore_flags(i32 %27)
%29 = load i64, i64* %6
%30 = call i32 @set_reg_n_int(i32 101, i64 %29)
br label %31
31: ; preds = %26, %2
%32 = load i32, i32* %5
%33 = zext i32 %32 to i64
%34 = call i32 @setX_int(i64 %33)
ret void
}

LLVM IR (-O2):
define void @justify(i64 (i64)* nocapture %0, i64 %1) {
%3 = tail call i64 (...) @getX_int()
%4 = tail call i32 (...) @setlastX()
%5 = tail call i32 (...) @lift()
%6 = icmp eq i64 %3, 0
br i1 %6, label %23, label %7
7: ; preds = %2
%8 = tail call i32 (...) @save_flags()
%9 = and i64 %3, %1
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %7, %11
%12 = phi i32 [ %15, %11 ], [ 0, %7 ]
%13 = phi i64 [ %14, %11 ], [ %3, %7 ]
%14 = tail call i64 %0(i64 %13)
%15 = add i32 %12, 1
%16 = and i64 %14, %1
%17 = icmp eq i64 %16, 0
br i1 %17, label %11, label %18
18: ; preds = %11, %7
%19 = phi i64 [ %3, %7 ], [ %14, %11 ]
%20 = phi i32 [ 0, %7 ], [ %15, %11 ]
%21 = tail call i32 @restore_flags(i32 %8)
%22 = tail call i32 @set_reg_n_int(i32 101, i64 %19)
br label %23
23: ; preds = %18, %2
%24 = phi i32 [ %20, %18 ], [ 0, %2 ]
%25 = zext i32 %24 to i64
%26 = tail call i32 @setX_int(i64 %25)
ret void
}