#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 pow(int, int);
int sat_25bits(int x) {
  int r;
  if (x > (pow(2, 24) - 1))
    r = (int)pow(2, 24) - 1;
  else if (x < -pow(2, 24))
    r = (int)-pow(2, 24);
  else
    r = (int)x;
  return r;
}


x86 assembly (clang, -O0):
<sat_25bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x2,%edi
mov    $0x18,%esi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    115a <sat_25bits+0x4a>
mov    $0x2,%edi
mov    $0x18,%esi
call   1030 <pow@plt>
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a8 <sat_25bits+0x98>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x2,%edi
mov    $0x18,%esi
call   1030 <pow@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%eax
xor    %ecx,%ecx
sub    %edx,%ecx
cmp    %ecx,%eax
jge    119d <sat_25bits+0x8d>
mov    $0x2,%edi
mov    $0x18,%esi
call   1030 <pow@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11a3 <sat_25bits+0x93>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11a8 <sat_25bits+0x98>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sat_25bits>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x2,%edi
mov    $0x18,%esi
call   1030 <pow@plt>
mov    %eax,%ebp
mov    $0x2,%edi
mov    $0x18,%esi
call   1030 <pow@plt>
cmp    %ebx,%ebp
jle    1154 <sat_25bits+0x44>
neg    %eax
cmp    %ebx,%eax
jle    1159 <sat_25bits+0x49>
mov    $0x2,%edi
mov    $0x18,%esi
call   1030 <pow@plt>
mov    %eax,%ebx
neg    %ebx
jmp    1159 <sat_25bits+0x49>
add    $0xffffffff,%eax
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sat_25bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @pow(i32 2, i32 24)
%6 = sub nsw i32 %5, 1
%7 = icmp sgt i32 %4, %6
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @pow(i32 2, i32 24)
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %3
br label %22
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i32 @pow(i32 2, i32 24)
%14 = sub nsw i32 0, %13
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = call i32 @pow(i32 2, i32 24)
%18 = sub nsw i32 0, %17
store i32 %18, i32* %3
br label %21
19: ; preds = %11
%20 = load i32, i32* %2
store i32 %20, i32* %3
br label %21
21: ; preds = %19, %16
br label %22
22: ; preds = %21, %8
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @sat_25bits(i32 %0) {
%2 = tail call i32 @pow(i32 2, i32 24)
%3 = icmp sgt i32 %2, %0
%4 = tail call i32 @pow(i32 2, i32 24)
br i1 %3, label %7, label %5
5: ; preds = %1
%6 = add nsw i32 %4, -1
br label %13
7: ; preds = %1
%8 = sub nsw i32 0, %4
%9 = icmp sgt i32 %8, %0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call i32 @pow(i32 2, i32 24)
%12 = sub nsw i32 0, %11
br label %13
13: ; preds = %7, %10, %5
%14 = phi i32 [ %6, %5 ], [ %12, %10 ], [ %0, %7 ]
ret i32 %14
}