#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 */
typedef int /*<<< orphan*/ numbers;

/* Variables and functions */
int EXIT_SUCCESS;
int get_most_significant_byte(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main(void) {
  int numbers[] = {0xFFEEEEEE, 0xE1234567, 0x87654321, 0xAC00BC01,
                   0x1FAABBCC, 0x57894232, 0xD1678992, 0xEF00FFFF};
  unsigned int elem_of_numbers = sizeof(numbers) / sizeof(numbers[0]);
  for (int i = 0; i < elem_of_numbers; i++) {
    int msb = get_most_significant_byte(numbers[i]);
    printf("MSB of %#X = %#X(%d)\n", numbers[i], msb, msb);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x8,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jae    11ad <main+0x8d>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
call   1030 <get_most_significant_byte@plt>
mov    %eax,-0x3c(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
mov    -0x3c(%rbp),%edx
mov    -0x3c(%rbp),%ecx
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1169 <main+0x49>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xffeeeeee,%edi
call   1030 <get_most_significant_byte@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0xffeeeeee,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0xe1234567,%edi
call   1030 <get_most_significant_byte@plt>
mov    %rbx,%rdi
mov    $0xe1234567,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0x87654321,%edi
call   1030 <get_most_significant_byte@plt>
mov    %rbx,%rdi
mov    $0x87654321,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0xac00bc01,%edi
call   1030 <get_most_significant_byte@plt>
mov    %rbx,%rdi
mov    $0xac00bc01,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0x1faabbcc,%edi
call   1030 <get_most_significant_byte@plt>
mov    %rbx,%rdi
mov    $0x1faabbcc,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0x57894232,%edi
call   1030 <get_most_significant_byte@plt>
mov    %rbx,%rdi
mov    $0x57894232,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0xd1678992,%edi
call   1030 <get_most_significant_byte@plt>
mov    %rbx,%rdi
mov    $0xd1678992,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0xef00ffff,%edi
call   1030 <get_most_significant_byte@plt>
mov    %rbx,%rdi
mov    $0xef00ffff,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.numbers = [8 x i32] [i32 -1118482, i32 -517782169, i32 -2023406815, i32 -1409238015, i32 531282892, i32 1468613170, i32 -781743726, i32 -285147137]
@.str = [22 x i8] c"MSB of %#X = %#X(%d)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [8 x i32]* %2 to i8*
store i32 8, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i32 @get_most_significant_byte(i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %5
%22 = load i32, i32* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
br label %24
24: ; preds = %11
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %7
27: ; preds = %7
%28 = load i32, i32* @EXIT_SUCCESS
ret i32 %28
}

LLVM IR (-O2):
@.str = [22 x i8] c"MSB of %#X = %#X(%d)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @get_most_significant_byte(i32 -1118482)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 -1118482, i32 %1, i32 %1)
%3 = tail call i32 @get_most_significant_byte(i32 -517782169)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 -517782169, i32 %3, i32 %3)
%5 = tail call i32 @get_most_significant_byte(i32 -2023406815)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 -2023406815, i32 %5, i32 %5)
%7 = tail call i32 @get_most_significant_byte(i32 -1409238015)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 -1409238015, i32 %7, i32 %7)
%9 = tail call i32 @get_most_significant_byte(i32 531282892)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 531282892, i32 %9, i32 %9)
%11 = tail call i32 @get_most_significant_byte(i32 1468613170)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1468613170, i32 %11, i32 %11)
%13 = tail call i32 @get_most_significant_byte(i32 -781743726)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 -781743726, i32 %13, i32 %13)
%15 = tail call i32 @get_most_significant_byte(i32 -285147137)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 -285147137, i32 %15, i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}