#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 scalar_t__ Pixmap;
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Bool;

/* Variables and functions */
scalar_t__ AddAttributesToDisplayOfCurrentMetaMode(int /*<<< orphan*/ *, int,
                                                   int, char *);
scalar_t__ ClonePixmap(int /*<<< orphan*/ *, int, scalar_t__);
scalar_t__ False;
scalar_t__ None;
int RemoveAttributeFromDisplayOfCurrentMetaMode(int /*<<< orphan*/ *, int, int,
                                                char const *);
int /*<<< orphan*/ XFreePixmap(int /*<<< orphan*/ *, scalar_t__);
scalar_t__ XNVCTRLBindWarpPixmapName(int /*<<< orphan*/ *, int, scalar_t__,
                                     char *, int /*<<< orphan*/,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ XSync(int /*<<< orphan*/ *, int /*<<< orphan*/);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, ...);
int SetPixmapDataToAttribute(Display *xDpy, int screenId, int nvDpyId,
                             Pixmap pixmap, Bool blendAfterWarp,
                             const char *attributeName) {
  Bool ret = False;
  char tempName[32];
  char newAttributes[256];
  if (pixmap == None) {
    return RemoveAttributeFromDisplayOfCurrentMetaMode(xDpy, screenId, nvDpyId,
                                                       attributeName);
  }
  pixmap = ClonePixmap(xDpy, screenId, pixmap);
  if (pixmap == None) {
    return 1;
  }
  sprintf(tempName, "%d", rand());
  if (blendAfterWarp) {
    sprintf(newAttributes, "%s=%s, BlendOrder=BlendAfterWarp", attributeName,
            tempName);
  } else {
    sprintf(newAttributes, "%s=%s, BlendOrder=WarpAfterBlend", attributeName,
            tempName);
  }
  ret = XNVCTRLBindWarpPixmapName(xDpy, screenId, pixmap, tempName, 0, 0);
  XFreePixmap(xDpy, pixmap);
  if (!ret) {
    return 1;
  }
  if (AddAttributesToDisplayOfCurrentMetaMode(xDpy, screenId, nvDpyId,
                                              newAttributes)) {
    return 1;
  }
  XSync(xDpy, 0);
  return 0;
}


x86 assembly (clang, -O0):
<SetPixmapDataToAttribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2e26(%rip),%rcx
cmp    (%rcx),%rax
jne    11de <SetPixmapDataToAttribute+0x5e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x30(%rbp),%rcx
call   1050 <RemoveAttributeFromDisplayOfCurrentMetaMode@plt>
mov    %eax,-0x4(%rbp)
jmp    1305 <SetPixmapDataToAttribute+0x185>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1080 <ClonePixmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2de3(%rip),%rcx
cmp    (%rcx),%rax
jne    1212 <SetPixmapDataToAttribute+0x92>
movl   $0x1,-0x4(%rbp)
jmp    1305 <SetPixmapDataToAttribute+0x185>
lea    -0x60(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    -0x168(%rbp),%rdi
mov    %eax,%edx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1268 <SetPixmapDataToAttribute+0xe8>
lea    -0x160(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    1285 <SetPixmapDataToAttribute+0x105>
lea    -0x160(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x60(%rbp),%rcx
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1070 <XNVCTRLBindWarpPixmapName@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <XFreePixmap@plt>
cmpq   $0x0,-0x38(%rbp)
jne    12c7 <SetPixmapDataToAttribute+0x147>
movl   $0x1,-0x4(%rbp)
jmp    1305 <SetPixmapDataToAttribute+0x185>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    -0x160(%rbp),%rcx
call   1030 <AddAttributesToDisplayOfCurrentMetaMode@plt>
cmp    $0x0,%rax
je     12f3 <SetPixmapDataToAttribute+0x173>
movl   $0x1,-0x4(%rbp)
jmp    1305 <SetPixmapDataToAttribute+0x185>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1060 <XSync@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetPixmapDataToAttribute>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %r9,%r12
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e48(%rip),%r15
cmp    %rcx,(%r15)
jne    11c3 <SetPixmapDataToAttribute+0x43>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12,%rcx
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <RemoveAttributeFromDisplayOfCurrentMetaMode@plt>
mov    %r8,%r14
mov    %edx,0xc(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rcx,%rdx
call   1080 <ClonePixmap@plt>
mov    %rax,%r13
mov    $0x1,%eax
cmp    (%r15),%r13
je     1287 <SetPixmapDataToAttribute+0x107>
xor    %eax,%eax
call   10a0 <rand@plt>
lea    0xe0a(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <sprintf@plt>
test   %r14,%r14
lea    0xe13(%rip),%rax
lea    0xdeb(%rip),%rsi
cmove  %rax,%rsi
lea    0x30(%rsp),%rdi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <XNVCTRLBindWarpPixmapName@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <XFreePixmap@plt>
test   %r14,%r14
je     1282 <SetPixmapDataToAttribute+0x102>
lea    0x30(%rsp),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    0xc(%rsp),%edx
call   1030 <AddAttributesToDisplayOfCurrentMetaMode@plt>
test   %rax,%rax
mov    $0x1,%eax
jne    1287 <SetPixmapDataToAttribute+0x107>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <XSync@plt>
xor    %eax,%eax
jmp    1287 <SetPixmapDataToAttribute+0x107>
mov    $0x1,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@False = global i64 0
@None = global i64 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [33 x i8] c"%s=%s, BlendOrder=BlendAfterWarp\00"
@.str.2 = [33 x i8] c"%s=%s, BlendOrder=WarpAfterBlend\00"
define i32 @SetPixmapDataToAttribute(i32* %0, i32 %1, i32 %2, i64 %3, i64 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca [32 x i8]
%16 = alloca [256 x i8]
store i32* %0, i32** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i64 %3, i64* %11
store i64 %4, i64* %12
store i8* %5, i8** %13
%17 = load i64, i64* @False
store i64 %17, i64* %14
%18 = load i64, i64* %11
%19 = load i64, i64* @None
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %6
%22 = load i32*, i32** %8
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = load i8*, i8** %13
%26 = call i32 @RemoveAttributeFromDisplayOfCurrentMetaMode(i32* %22, i32 %23, i32 %24, i8* %25)
store i32 %26, i32* %7
br label %75
27: ; preds = %6
%28 = load i32*, i32** %8
%29 = load i32, i32* %9
%30 = load i64, i64* %11
%31 = call i64 @ClonePixmap(i32* %28, i32 %29, i64 %30)
store i64 %31, i64* %11
%32 = load i64, i64* %11
%33 = load i64, i64* @None
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %27
store i32 1, i32* %7
br label %75
36: ; preds = %27
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%38 = call i32 (...) @rand()
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = load i64, i64* %12
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %36
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%44 = load i8*, i8** %13
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %43, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %44, i8* %45)
br label %52
47: ; preds = %36
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%49 = load i8*, i8** %13
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%51 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %49, i8* %50)
br label %52
52: ; preds = %47, %42
%53 = load i32*, i32** %8
%54 = load i32, i32* %9
%55 = load i64, i64* %11
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%57 = call i64 @XNVCTRLBindWarpPixmapName(i32* %53, i32 %54, i64 %55, i8* %56, i32 0, i32 0)
store i64 %57, i64* %14
%58 = load i32*, i32** %8
%59 = load i64, i64* %11
%60 = call i32 @XFreePixmap(i32* %58, i64 %59)
%61 = load i64, i64* %14
%62 = icmp ne i64 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %52
store i32 1, i32* %7
br label %75
64: ; preds = %52
%65 = load i32*, i32** %8
%66 = load i32, i32* %9
%67 = load i32, i32* %10
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%69 = call i64 @AddAttributesToDisplayOfCurrentMetaMode(i32* %65, i32 %66, i32 %67, i8* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %64
store i32 1, i32* %7
br label %75
72: ; preds = %64
%73 = load i32*, i32** %8
%74 = call i32 @XSync(i32* %73, i32 0)
store i32 0, i32* %7
br label %75
75: ; preds = %72, %71, %63, %35, %21
%76 = load i32, i32* %7
ret i32 %76
}

LLVM IR (-O2):
@False = global i64 0
@None = global i64 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [33 x i8] c"%s=%s, BlendOrder=BlendAfterWarp\00"
@.str.2 = [33 x i8] c"%s=%s, BlendOrder=WarpAfterBlend\00"
define i32 @SetPixmapDataToAttribute(i32* %0, i32 %1, i32 %2, i64 %3, i64 %4, i8* %5) {
%7 = alloca [32 x i8]
%8 = alloca [256 x i8]
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%11 = load i64, i64* @None
%12 = icmp eq i64 %11, %3
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @RemoveAttributeFromDisplayOfCurrentMetaMode(i32* %0, i32 %1, i32 %2, i8* %5)
br label %33
15: ; preds = %6
%16 = tail call i64 @ClonePixmap(i32* %0, i32 %1, i64 %3)
%17 = load i64, i64* @None
%18 = icmp eq i64 %16, %17
br i1 %18, label %33, label %19
19: ; preds = %15
%20 = tail call i32 (...) @rand()
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = icmp eq i64 %4, 0
%23 = select i1 %22, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0)
%24 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* dereferenceable(1) %23, i8* %5, i8* %9)
%25 = call i64 @XNVCTRLBindWarpPixmapName(i32* %0, i32 %1, i64 %16, i8* %9, i32 0, i32 0)
%26 = call i32 @XFreePixmap(i32* %0, i64 %16)
%27 = icmp eq i64 %25, 0
br i1 %27, label %33, label %28
28: ; preds = %19
%29 = call i64 @AddAttributesToDisplayOfCurrentMetaMode(i32* %0, i32 %1, i32 %2, i8* %10)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @XSync(i32* %0, i32 0)
br label %33
33: ; preds = %28, %19, %15, %31, %13
%34 = phi i32 [ %14, %13 ], [ 0, %31 ], [ 1, %15 ], [ 1, %19 ], [ 1, %28 ]
ret i32 %34
}