#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*/ printf(char *, int, int);
int main(int argc, char **argv) {
  int var32 = 0;
  var32 = 0xffed91;
  printf("Integer as read 24-bit value in  32 bit register 0x%x %d\n", var32,
         var32);
  if (var32 & 0x100000) {
    var32 |= 0xFF000000;
    printf("Negative number is 0x%x %d\n", var32, var32);
  } else {
    printf("Positive number is 0x%x %d", var32, var32);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffed91,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x100000,%eax
cmp    $0x0,%eax
je     1179 <main+0x69>
mov    -0x14(%rbp),%eax
or     $0xff000000,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <main+0x7b>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0xffed91,%esi
mov    $0xffed91,%edx
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
mov    $0xffffed91,%esi
mov    $0xffffed91,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Integer as read 24-bit value in 32 bit register 0x%x %d\0A\00"
@.str.1 = [28 x i8] c"Negative number is 0x%x %d\0A\00"
@.str.2 = [27 x i8] c"Positive number is 0x%x %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 16772497, i32* %6
%7 = load i32, i32* %6
%8 = load i32, i32* %6
%9 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* %6
%11 = and i32 %10, 1048576
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* %6
%15 = or i32 %14, -16777216
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
br label %23
19: ; preds = %2
%20 = load i32, i32* %6
%21 = load i32, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
br label %23
23: ; preds = %19, %13
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [58 x i8] c"Integer as read 24-bit value in 32 bit register 0x%x %d\0A\00"
@.str.1 = [28 x i8] c"Negative number is 0x%x %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 16772497, i32 16772497)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 -4719, i32 -4719)
ret i32 0
}