#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 *, short, short);
int int_test(long l, int i, short s) {
  printf("long  = %ld(%lX)\n", l, l);
  printf("int   = %d(%X)\n", i, i);
  printf("short = %d(%X)\n", s, s);
  return l + i + s;
}


x86 assembly (clang, -O0):
<int_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dx,%ax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %ax,-0xe(%rbp)
mov    -0x8(%rbp),%rax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
lea    0xec8(%rip),%rdi
movswl %cx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %ax,%cx
mov    -0xc(%rbp),%eax
lea    0xebf(%rip),%rdi
movswl %cx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
mov    -0xe(%rbp),%ax
lea    0xeb9(%rip),%rdi
movswl %ax,%esi
movswl -0xe(%rbp),%edx
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
movswq -0xe(%rbp),%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_test>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
movswl %r14w,%edx
lea    0xeda(%rip),%rdi
mov    %edx,%esi
call   1030 <printf@plt>
movswl %bp,%edx
lea    0xedb(%rip),%rdi
mov    %edx,%esi
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
add    %r14d,%ebp
add    %ebx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"long = %ld(%lX)\0A\00"
@.str.1 = [16 x i8] c"int = %d(%X)\0A\00"
@.str.2 = [16 x i8] c"short = %d(%X)\0A\00"
define i32 @int_test(i64 %0, i32 %1, i16 signext %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i16
store i64 %0, i64* %4
store i32 %1, i32* %5
store i16 %2, i16* %6
%7 = load i64, i64* %4
%8 = trunc i64 %7 to i16
%9 = load i64, i64* %4
%10 = trunc i64 %9 to i16
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i16 signext %8, i16 signext %10)
%12 = load i32, i32* %5
%13 = trunc i32 %12 to i16
%14 = load i32, i32* %5
%15 = trunc i32 %14 to i16
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i16 signext %13, i16 signext %15)
%17 = load i16, i16* %6
%18 = load i16, i16* %6
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i16 signext %17, i16 signext %18)
%20 = load i64, i64* %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = add nsw i64 %20, %22
%24 = load i16, i16* %6
%25 = sext i16 %24 to i64
%26 = add nsw i64 %23, %25
%27 = trunc i64 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
@.str = [18 x i8] c"long = %ld(%lX)\0A\00"
@.str.1 = [16 x i8] c"int = %d(%X)\0A\00"
@.str.2 = [16 x i8] c"short = %d(%X)\0A\00"
define i32 @int_test(i64 %0, i32 %1, i16 signext %2) {
%4 = trunc i64 %0 to i16
%5 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i16 signext %4, i16 signext %4)
%6 = trunc i32 %1 to i16
%7 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i16 signext %6, i16 signext %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i16 signext %2, i16 signext %2)
%9 = zext i32 %1 to i64
%10 = add i64 %9, %0
%11 = sext i16 %2 to i64
%12 = add i64 %10, %11
%13 = trunc i64 %12 to i32
ret i32 %13
}