#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 uint32_t;
struct can_bittiming {
  int phase_seg2;
  int phase_seg1;
  int prop_seg;
  int sjw;
  int brp;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printf_btr_at91(struct can_bittiming *bt, bool hdr) {
  if (hdr) {
    printf("%10s", "CAN_BR");
  } else {
    uint32_t br = ((bt->phase_seg2 - 1) | ((bt->phase_seg1 - 1) << 4) |
                   ((bt->prop_seg - 1) << 8) | ((bt->sjw - 1) << 12) |
                   ((bt->brp - 1) << 16));
    printf("0x%08x", br);
  }
}


x86 assembly (clang, -O0):
<printf_btr_at91>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1143 <printf_btr_at91+0x33>
lea    0xed0(%rip),%rdi
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119c <printf_btr_at91+0x8c>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    -0x8(%rbp),%rcx
mov    0x4(%rcx),%ecx
sub    $0x1,%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%ecx
sub    $0x1,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0xc(%rcx),%ecx
sub    $0x1,%ecx
shl    $0xc,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x10(%rcx),%ecx
sub    $0x1,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_btr_at91>:
test   %esi,%esi
je     1129 <printf_btr_at91+0x19>
lea    0xee5(%rip),%rdi
lea    0xee3(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
add    $0xffffffff,%eax
shl    $0x4,%ecx
add    $0xfffffff0,%ecx
or     %eax,%ecx
mov    0x8(%rdi),%eax
shl    $0x8,%eax
add    $0xffffff00,%eax
mov    0xc(%rdi),%edx
shl    $0xc,%edx
add    $0xfffff000,%edx
or     %eax,%edx
or     %ecx,%edx
mov    0x10(%rdi),%esi
shl    $0x10,%esi
add    $0xffff0000,%esi
or     %edx,%esi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.can_bittiming = type { i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"%10s\00"
@.str.1 = [7 x i8] c"CAN_BR\00"
@.str.2 = [7 x i8] c"0x%08x\00"
define void @printf_btr_at91(%struct.can_bittiming* %0, i32 %1) {
%3 = alloca %struct.can_bittiming*
%4 = alloca i32
%5 = alloca i32
store %struct.can_bittiming* %0, %struct.can_bittiming** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %41
10: ; preds = %2
%11 = load %struct.can_bittiming*, %struct.can_bittiming** %3
%12 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = sub nsw i32 %13, 1
%15 = load %struct.can_bittiming*, %struct.can_bittiming** %3
%16 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = sub nsw i32 %17, 1
%19 = shl i32 %18, 4
%20 = or i32 %14, %19
%21 = load %struct.can_bittiming*, %struct.can_bittiming** %3
%22 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %21, i32 0, i32 2
%23 = load i32, i32* %22
%24 = sub nsw i32 %23, 1
%25 = shl i32 %24, 8
%26 = or i32 %20, %25
%27 = load %struct.can_bittiming*, %struct.can_bittiming** %3
%28 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %27, i32 0, i32 3
%29 = load i32, i32* %28
%30 = sub nsw i32 %29, 1
%31 = shl i32 %30, 12
%32 = or i32 %26, %31
%33 = load %struct.can_bittiming*, %struct.can_bittiming** %3
%34 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %33, i32 0, i32 4
%35 = load i32, i32* %34
%36 = sub nsw i32 %35, 1
%37 = shl i32 %36, 16
%38 = or i32 %32, %37
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %10, %8
ret void
}

LLVM IR (-O2):
%struct.can_bittiming = type { i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"%10s\00"
@.str.1 = [7 x i8] c"CAN_BR\00"
@.str.2 = [7 x i8] c"0x%08x\00"
define void @printf_btr_at91(%struct.can_bittiming* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %31
6: ; preds = %2
%7 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, -1
%10 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %0, i64 0, i32 1
%11 = load i32, i32* %10
%12 = shl i32 %11, 4
%13 = add i32 %12, -16
%14 = or i32 %13, %9
%15 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %0, i64 0, i32 2
%16 = load i32, i32* %15
%17 = shl i32 %16, 8
%18 = add i32 %17, -256
%19 = or i32 %14, %18
%20 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %0, i64 0, i32 3
%21 = load i32, i32* %20
%22 = shl i32 %21, 12
%23 = add i32 %22, -4096
%24 = or i32 %19, %23
%25 = getelementptr inbounds %struct.can_bittiming, %struct.can_bittiming* %0, i64 0, i32 4
%26 = load i32, i32* %25
%27 = shl i32 %26, 16
%28 = add i32 %27, -65536
%29 = or i32 %24, %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %6, %4
ret void
}