#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 __nv_ffs(int);
int __nv_ffsll(int);
int /*<<< orphan*/ printf(char *, ...);
int test2() {
  int result;
#pragma omp target map(tofrom : result)
  { result = __nv_ffsll(0xf4); }
  int host = __nv_ffsll(0xf4);
  if (result != host) {
    printf("ffsll test failed! result = %d, expecting %d\n", result, host);
    return 1;
  }
  printf("ffsll test OK!\n");
#pragma omp target map(tofrom : result)
  { result = __nv_ffs(0xf4); }
  host = __nv_ffs(0xf4);
  if (result != host) {
    printf("ffs test failed! result = %d, expecting %d\n", result, host);
    return 1;
  }
  printf("ffs test OK!\n");
  return 0;
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xf4,%edi
call   1030 <__nv_ffsll@plt>
mov    %eax,-0x8(%rbp)
mov    $0xf4,%edi
call   1030 <__nv_ffsll@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     117e <test2+0x4e>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e7 <test2+0xb7>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xf4,%edi
call   1050 <__nv_ffs@plt>
mov    %eax,-0x8(%rbp)
mov    $0xf4,%edi
call   1050 <__nv_ffs@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11d2 <test2+0xa2>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e7 <test2+0xb7>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
push   %rbx
mov    $0xf4,%edi
call   1040 <__nv_ffsll@plt>
mov    %eax,%ebx
mov    $0xf4,%edi
call   1040 <__nv_ffsll@plt>
cmp    %eax,%ebx
jne    1191 <test2+0x51>
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
mov    $0xf4,%edi
call   1060 <__nv_ffs@plt>
mov    %eax,%ebx
mov    $0xf4,%edi
call   1060 <__nv_ffs@plt>
cmp    %eax,%ebx
jne    119a <test2+0x5a>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe68(%rip),%rdi
jmp    11a1 <test2+0x61>
lea    0xe8d(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"ffsll test failed! result = %d, expecting %d\0A\00"
@.str.1 = [16 x i8] c"ffsll test OK!\0A\00"
@.str.2 = [44 x i8] c"ffs test failed! result = %d, expecting %d\0A\00"
@.str.3 = [14 x i8] c"ffs test OK!\0A\00"
define i32 @test2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @__nv_ffsll(i32 244)
store i32 %4, i32* %2
%5 = call i32 @__nv_ffsll(i32 244)
store i32 %5, i32* %3
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
store i32 1, i32* %1
br label %26
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @__nv_ffs(i32 244)
store i32 %15, i32* %2
%16 = call i32 @__nv_ffs(i32 244)
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %22)
store i32 1, i32* %1
br label %26
24: ; preds = %13
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %26
26: ; preds = %24, %20, %9
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [46 x i8] c"ffsll test failed! result = %d, expecting %d\0A\00"
@.str.2 = [44 x i8] c"ffs test failed! result = %d, expecting %d\0A\00"
@str = [15 x i8] c"ffsll test OK!\00"
@str.4 = [13 x i8] c"ffs test OK!\00"
define i32 @test2() {
%1 = tail call i32 @__nv_ffsll(i32 244)
%2 = tail call i32 @__nv_ffsll(i32 244)
%3 = icmp eq i32 %1, %2
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
br label %15
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @__nv_ffs(i32 244)
%9 = tail call i32 @__nv_ffs(i32 244)
%10 = icmp eq i32 %8, %9
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
br label %15
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
br label %15
15: ; preds = %13, %11, %4
%16 = phi i32 [ 1, %4 ], [ 1, %11 ], [ 0, %13 ]
ret i32 %16
}