void lcdc_samsung_panel_power(int on) {
  int n, ret = 0;
  display_common_power(on);
  for (n = 0; n < 28; n++) {
    if (on) {
      ret = gpio_request(0 + n, "LCDC_GPIO");
      if (unlikely(ret)) {
        pr_err("%s not able to get gpio\n", __func__);
        break;
      }
    } else
      gpio_free(0 + n);
  }
  if (ret) {
    for (n--; n >= 0; n--)
      gpio_free(0 + n);
  }
}


x86 assembly (clang, -O0):
<lcdc_samsung_panel_power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <display_common_power@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1c,-0x8(%rbp)
jge    11f0 <lcdc_samsung_panel_power+0xa0>
cmpl   $0x0,-0x4(%rbp)
je     11d0 <lcdc_samsung_panel_power+0x80>
mov    -0x8(%rbp),%edi
add    $0x0,%edi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <gpio_request@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1070 <unlikely@plt>
cmp    $0x0,%eax
je     11cb <lcdc_samsung_panel_power+0x7b>
lea    0xe52(%rip),%rdi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1060 <pr_err@plt>
jmp    11f0 <lcdc_samsung_panel_power+0xa0>
jmp    11dd <lcdc_samsung_panel_power+0x8d>
mov    -0x8(%rbp),%edi
add    $0x0,%edi
mov    $0x0,%al
call   1030 <gpio_free@plt>
jmp    11e2 <lcdc_samsung_panel_power+0x92>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <lcdc_samsung_panel_power+0x23>
cmpl   $0x0,-0xc(%rbp)
je     122d <lcdc_samsung_panel_power+0xdd>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1228 <lcdc_samsung_panel_power+0xd8>
mov    -0x8(%rbp),%edi
add    $0x0,%edi
mov    $0x0,%al
call   1030 <gpio_free@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1203 <lcdc_samsung_panel_power+0xb3>
jmp    122d <lcdc_samsung_panel_power+0xdd>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcdc_samsung_panel_power>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
xor    %eax,%eax
call   1050 <display_common_power@plt>
lea    0xe98(%rip),%r15
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    117f <lcdc_samsung_panel_power+0x2f>
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <gpio_free@plt>
add    $0x1,%ebx
cmp    $0x1c,%ebx
je     11ba <lcdc_samsung_panel_power+0x6a>
mov    %ebx,%edi
test   %r14d,%r14d
je     1170 <lcdc_samsung_panel_power+0x20>
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <gpio_request@plt>
mov    %eax,%ebp
mov    %eax,%edi
xor    %eax,%eax
call   1070 <unlikely@plt>
test   %eax,%eax
je     1177 <lcdc_samsung_panel_power+0x27>
lea    0xe64(%rip),%rdi
lea    0xe76(%rip),%rsi
xor    %eax,%eax
call   1060 <pr_err@plt>
test   %ebp,%ebp
jne    11c3 <lcdc_samsung_panel_power+0x73>
jmp    11e2 <lcdc_samsung_panel_power+0x92>
mov    $0x1c,%ebx
test   %ebp,%ebp
je     11e2 <lcdc_samsung_panel_power+0x92>
test   %ebx,%ebx
je     11e2 <lcdc_samsung_panel_power+0x92>
add    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%edi
xor    %eax,%eax
call   1030 <gpio_free@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     11d0 <lcdc_samsung_panel_power+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"LCDC_GPIO\00"
@.str.1 = [25 x i8] c"%s not able to get gpio\0A\00"
@__func__.lcdc_samsung_panel_power = [25 x i8] c"lcdc_samsung_panel_power\00"
define void @lcdc_samsung_panel_power(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
%5 = load i32, i32* %2
%6 = call i32 (i32, ...) bitcast (i32 (...)* @display_common_power to i32 (i32, ...)*)(i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %28, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 28
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %3
%15 = add nsw i32 0, %14
%16 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @gpio_request to i32 (i32, i8*, ...)*)(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = call i32 (i32, ...) bitcast (i32 (...)* @unlikely to i32 (i32, ...)*)(i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @__func__.lcdc_samsung_panel_power, i64 0, i64 0))
br label %31
22: ; preds = %13
br label %27
23: ; preds = %10
%24 = load i32, i32* %3
%25 = add nsw i32 0, %24
%26 = call i32 (i32, ...) bitcast (i32 (...)* @gpio_free to i32 (i32, ...)*)(i32 %25)
br label %27
27: ; preds = %23, %22
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %7
31: ; preds = %20, %7
%32 = load i32, i32* %4
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %48
34: ; preds = %31
%35 = load i32, i32* %3
%36 = add nsw i32 %35, -1
store i32 %36, i32* %3
br label %37
37: ; preds = %44, %34
%38 = load i32, i32* %3
%39 = icmp sge i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i32, i32* %3
%42 = add nsw i32 0, %41
%43 = call i32 (i32, ...) bitcast (i32 (...)* @gpio_free to i32 (i32, ...)*)(i32 %42)
br label %44
44: ; preds = %40
%45 = load i32, i32* %3
%46 = add nsw i32 %45, -1
store i32 %46, i32* %3
br label %37
47: ; preds = %37
br label %48
48: ; preds = %47, %31
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"LCDC_GPIO\00"
@.str.1 = [25 x i8] c"%s not able to get gpio\0A\00"
@__func__.lcdc_samsung_panel_power = [25 x i8] c"lcdc_samsung_panel_power\00"
define void @lcdc_samsung_panel_power(i32 %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @display_common_power to i32 (i32, ...)*)(i32 %0)
%3 = icmp eq i32 %0, 0
br label %4
4: ; preds = %1, %15
%5 = phi i32 [ 0, %1 ], [ %16, %15 ]
%6 = phi i32 [ 0, %1 ], [ %17, %15 ]
br i1 %3, label %13, label %7
7: ; preds = %4
%8 = tail call i32 (i32, i8*, ...) bitcast (i32 (...)* @gpio_request to i32 (i32, i8*, ...)*)(i32 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (i32, ...) bitcast (i32 (...)* @unlikely to i32 (i32, ...)*)(i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @__func__.lcdc_samsung_panel_power, i64 0, i64 0))
br label %19
13: ; preds = %4
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @gpio_free to i32 (i32, ...)*)(i32 %6)
br label %15
15: ; preds = %13, %7
%16 = phi i32 [ %8, %7 ], [ %5, %13 ]
%17 = add nuw nsw i32 %6, 1
%18 = icmp eq i32 %17, 28
br i1 %18, label %19, label %4
19: ; preds = %15, %11
%20 = phi i32 [ %6, %11 ], [ 28, %15 ]
%21 = phi i32 [ %8, %11 ], [ %16, %15 ]
%22 = icmp ne i32 %21, 0
%23 = icmp ne i32 %20, 0
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %25, label %30
25: ; preds = %19, %25
%26 = phi i32 [ %27, %25 ], [ %20, %19 ]
%27 = add nsw i32 %26, -1
%28 = tail call i32 (i32, ...) bitcast (i32 (...)* @gpio_free to i32 (i32, ...)*)(i32 %27)
%29 = icmp sgt i32 %26, 1
br i1 %29, label %25, label %30
30: ; preds = %25, %19
ret void
}