#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 */
struct scsi_cmnd {
  int dummy;
};
struct lpfc_hba {
  int dummy;
};

/* Variables and functions */
void *scsi_sglist(struct scsi_cmnd *);
void *sg_next(void *);
void lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
                       unsigned *pde5) {
  void *sgde;
  int i;
  *pde5 = (((0x85 & 0x000000ff) << 24) | (*pde5 & ~(0x000000ff << 24)));
  for (i = 0, sgde = scsi_sglist(sc); i < 2; i++, sgde = sg_next(sgde))
    ;
}


x86 assembly (clang, -O0):
<lpfc_bg_setup_bpl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
and    $0xffffff,%ecx
or     $0x85000000,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <scsi_sglist@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    118a <lpfc_bg_setup_bpl+0x6a>
jmp    116f <lpfc_bg_setup_bpl+0x4f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <sg_next@plt>
mov    %rax,-0x20(%rbp)
jmp    1160 <lpfc_bg_setup_bpl+0x40>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lpfc_bg_setup_bpl>:
push   %rax
mov    %rsi,%rdi
movb   $0x85,0x3(%rdx)
call   1030 <scsi_sglist@plt>
mov    %rax,%rdi
call   1040 <sg_next@plt>
mov    %rax,%rdi
pop    %rax
jmp    1040 <sg_next@plt>

LLVM IR (-O0):
%struct.lpfc_hba = type { i32 }
%struct.scsi_cmnd = type { i32 }
define void @lpfc_bg_setup_bpl(%struct.lpfc_hba* %0, %struct.scsi_cmnd* %1, i32* %2) {
%4 = alloca %struct.lpfc_hba*
%5 = alloca %struct.scsi_cmnd*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store %struct.lpfc_hba* %0, %struct.lpfc_hba** %4
store %struct.scsi_cmnd* %1, %struct.scsi_cmnd** %5
store i32* %2, i32** %6
%9 = load i32*, i32** %6
%10 = load i32, i32* %9
%11 = and i32 %10, 16777215
%12 = or i32 -2063597568, %11
%13 = load i32*, i32** %6
store i32 %12, i32* %13
store i32 0, i32* %8
%14 = load %struct.scsi_cmnd*, %struct.scsi_cmnd** %5
%15 = call i8* @scsi_sglist(%struct.scsi_cmnd* %14)
store i8* %15, i8** %7
br label %16
16: ; preds = %20, %3
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %16
br label %20
20: ; preds = %19
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
%23 = load i8*, i8** %7
%24 = call i8* @sg_next(i8* %23)
store i8* %24, i8** %7
br label %16
25: ; preds = %16
ret void
}

LLVM IR (-O2):
%struct.lpfc_hba = type { i32 }
%struct.scsi_cmnd = type { i32 }
define void @lpfc_bg_setup_bpl(%struct.lpfc_hba* nocapture readnone %0, %struct.scsi_cmnd* %1, i32* nocapture %2) {
%4 = load i32, i32* %2
%5 = and i32 %4, 16777215
%6 = or i32 %5, -2063597568
store i32 %6, i32* %2
%7 = tail call i8* @scsi_sglist(%struct.scsi_cmnd* %1)
%8 = tail call i8* @sg_next(i8* %7)
%9 = tail call i8* @sg_next(i8* %8)
ret void
}