#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 *, unsigned char, unsigned short, unsigned char,
                          unsigned short, unsigned short);
unsigned short test_func_fn(unsigned char a1, unsigned short a2,
                            unsigned char a3, unsigned short a4) {
  unsigned short result;
  result = a1 + a2 + a3 + a4;
  printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
  return result;
}


x86 assembly (clang, -O0):
<test_func_fn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cx,%ax
mov    %dl,%cl
mov    %si,%dx
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dx,-0x4(%rbp)
mov    %cl,-0x5(%rbp)
mov    %ax,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
movzwl -0x4(%rbp),%ecx
add    %ecx,%eax
movzbl -0x5(%rbp),%ecx
add    %ecx,%eax
movzwl -0x8(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0xa(%rbp)
mov    -0x1(%rbp),%sil
mov    -0x4(%rbp),%dx
mov    -0x5(%rbp),%cl
mov    -0x8(%rbp),%ax
lea    0xe9e(%rip),%rdi
movzbl %sil,%esi
movzwl %dx,%edx
movzbl %cl,%ecx
movzwl %ax,%r8d
movzwl -0xa(%rbp),%r9d
call   1030 <printf@plt>
movzwl -0xa(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_func_fn>:
push   %rbx
mov    %ecx,%r8d
mov    %edx,%ecx
mov    %esi,%edx
mov    %edi,%esi
lea    (%rsi,%rdx,1),%eax
add    %ecx,%eax
add    %r8d,%eax
movzwl %ax,%ebx
lea    0xed4(%rip),%rdi
mov    %ebx,%r9d
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"%d %d %d %d: %d\0A\00"
define zeroext i16 @test_func_fn(i8 zeroext %0, i16 zeroext %1, i8 zeroext %2, i16 zeroext %3) {
%5 = zext i8 %0 to i16
%6 = add i16 %5, %1
%7 = zext i8 %2 to i16
%8 = add i16 %6, %7
%9 = add i16 %8, %3
%10 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 zeroext %0, i16 zeroext %1, i8 zeroext %2, i16 zeroext %3, i16 zeroext %9)
ret i16 %9
}