#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 __builtin_HEXAGON_L2_loadri_pci(void *, int, int, void *);
int bar(void *p, void *q, int x) {
  return __builtin_HEXAGON_L2_loadri_pci(p, -1, x, q) +
         __builtin_HEXAGON_L2_loadri_pci(p, -99, x, q) +
         __builtin_HEXAGON_L2_loadri_pci(p, -132, x, q) +
         __builtin_HEXAGON_L2_loadri_pci(p, 28, x, q) +
         __builtin_HEXAGON_L2_loadri_pci(p, 29, x, q);
}


x86 assembly (clang, -O0):
<bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0xffffffff,%esi
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0xffffff9d,%esi
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0xffffff7c,%esi
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1c,%esi
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1d,%esi
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r13
mov    $0xffffffff,%esi
mov    %r14,%rcx
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%r15d
mov    %r13,%rdi
mov    $0xffffff9d,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%ebp
add    %r15d,%ebp
mov    %r13,%rdi
mov    $0xffffff7c,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r13,%rdi
mov    $0x1c,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r13,%rdi
mov    $0x1d,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1030 <__builtin_HEXAGON_L2_loadri_pci@plt>
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @bar(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load i32, i32* %6
%9 = load i8*, i8** %5
%10 = call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %7, i32 -1, i32 %8, i8* %9)
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = load i8*, i8** %5
%14 = call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %11, i32 -99, i32 %12, i8* %13)
%15 = add nsw i32 %10, %14
%16 = load i8*, i8** %4
%17 = load i32, i32* %6
%18 = load i8*, i8** %5
%19 = call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %16, i32 -132, i32 %17, i8* %18)
%20 = add nsw i32 %15, %19
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = load i8*, i8** %5
%24 = call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %21, i32 28, i32 %22, i8* %23)
%25 = add nsw i32 %20, %24
%26 = load i8*, i8** %4
%27 = load i32, i32* %6
%28 = load i8*, i8** %5
%29 = call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %26, i32 29, i32 %27, i8* %28)
%30 = add nsw i32 %25, %29
ret i32 %30
}

LLVM IR (-O2):
define i32 @bar(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %0, i32 -1, i32 %2, i8* %1)
%5 = tail call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %0, i32 -99, i32 %2, i8* %1)
%6 = add nsw i32 %5, %4
%7 = tail call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %0, i32 -132, i32 %2, i8* %1)
%8 = add nsw i32 %6, %7
%9 = tail call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %0, i32 28, i32 %2, i8* %1)
%10 = add nsw i32 %8, %9
%11 = tail call i32 @__builtin_HEXAGON_L2_loadri_pci(i8* %0, i32 29, i32 %2, i8* %1)
%12 = add nsw i32 %10, %11
ret i32 %12
}