#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 __u8;
typedef int __u16;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
__u8 mode_loop(__u16 mode_sup, __u16 mode_sel, int cc, __u8 *have_mode) {
  __u16 ii;
  __u8 err_dma = 0;
  for (ii = 0; ii <= 7; ii++) {
    if (mode_sel & 0x0001) {
      printf("*%cdma%u ", cc, ii);
      if (*have_mode)
        err_dma = 1;
      *have_mode = 1;
    } else if (mode_sup & 0x0001) {
      printf("%cdma%u ", cc, ii);
    }
    mode_sup >>= 1;
    mode_sel >>= 1;
  }
  return err_dma;
}


x86 assembly (clang, -O0):
<mode_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jg     11c7 <mode_loop+0xb7>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1181 <mode_loop+0x71>
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     1172 <mode_loop+0x62>
movl   $0x1,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11a7 <mode_loop+0x97>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a2 <mode_loop+0x92>
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    11a7 <mode_loop+0x97>
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <mode_loop+0x23>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_loop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    1164 <mode_loop+0x54>
nopl   (%rax)
lea    0xec9(%rip),%rdi
mov    %r14d,%esi
mov    %r13d,%edx
call   1030 <printf@plt>
cmpl   $0x0,(%r15)
mov    $0x1,%eax
cmovne %eax,%r12d
movl   $0x1,(%r15)
sar    %ebx
sar    %ebp
add    $0x1,%r13d
cmp    $0x8,%r13d
je     1183 <mode_loop+0x73>
test   $0x1,%bpl
jne    1130 <mode_loop+0x20>
test   $0x1,%bl
je     1156 <mode_loop+0x46>
lea    0xe8b(%rip),%rdi
mov    %r14d,%esi
mov    %r13d,%edx
call   1030 <printf@plt>
jmp    1156 <mode_loop+0x46>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"*%cdma%u \00"
@.str.1 = [9 x i8] c"%cdma%u \00"
define i32 @mode_loop(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i32 0, i32* %10
store i32 0, i32* %9
br label %11
11: ; preds = %42, %4
%12 = load i32, i32* %9
%13 = icmp sle i32 %12, 7
br i1 %13, label %14, label %45
14: ; preds = %11
%15 = load i32, i32* %6
%16 = and i32 %15, 1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32, i32* %7
%20 = load i32, i32* %9
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20)
%22 = load i32*, i32** %8
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %18
store i32 1, i32* %10
br label %26
26: ; preds = %25, %18
%27 = load i32*, i32** %8
store i32 1, i32* %27
br label %37
28: ; preds = %14
%29 = load i32, i32* %5
%30 = and i32 %29, 1
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* %7
%34 = load i32, i32* %9
%35 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34)
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36, %26
%38 = load i32, i32* %5
%39 = ashr i32 %38, 1
store i32 %39, i32* %5
%40 = load i32, i32* %6
%41 = ashr i32 %40, 1
store i32 %41, i32* %6
br label %42
42: ; preds = %37
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %11
45: ; preds = %11
%46 = load i32, i32* %10
ret i32 %46
}

LLVM IR (-O2):
@.str = [10 x i8] c"*%cdma%u \00"
@.str.1 = [9 x i8] c"%cdma%u \00"
define i32 @mode_loop(i32 %0, i32 %1, i32 %2, i32* nocapture %3) {
br label %5
5: ; preds = %4, %22
%6 = phi i32 [ 0, %4 ], [ %23, %22 ]
%7 = phi i32 [ 0, %4 ], [ %26, %22 ]
%8 = phi i32 [ %0, %4 ], [ %24, %22 ]
%9 = phi i32 [ %1, %4 ], [ %25, %22 ]
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %5
%13 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %7)
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 %6, i32 1
store i32 1, i32* %3
br label %22
17: ; preds = %5
%18 = and i32 %8, 1
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %7)
br label %22
22: ; preds = %17, %20, %12
%23 = phi i32 [ %16, %12 ], [ %6, %20 ], [ %6, %17 ]
%24 = ashr i32 %8, 1
%25 = ashr i32 %9, 1
%26 = add nuw nsw i32 %7, 1
%27 = icmp eq i32 %26, 8
br i1 %27, label %28, label %5
28: ; preds = %22
ret i32 %23
}