#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 /*<<< orphan*/ printf(char *, ...);
int check_assignment(int *assignment, int nvtxs, int nsets_tot, int ndims,
                     int local_method) {
  int flag;
  int nsets;
  int i;
  nsets = 1 << ndims;
  flag = 0;
  for (i = 1; i <= nvtxs && !flag; i++) {
    if (assignment[i] < 0) {
      printf("Assignment[%d] = %d less than zero.\n", i, assignment[i]);
      flag = 1;
    } else if (assignment[i] >= nsets_tot) {
      printf("Assignment[%d] = %d, too large for %d sets.\n", i, assignment[i],
             nsets_tot);
      flag = 1;
    } else if (local_method == 1 && assignment[i] >= nsets) {
      printf(
          "Can only use local method on single level of read-in assignment,\n");
      printf("  but assignment[%d] =  %d.\n", i, assignment[i]);
      flag = 1;
    }
  }
  return (flag);
}


x86 assembly (clang, -O0):
<check_assignment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x25(%rbp)
jg     1161 <check_assignment+0x51>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1171 <check_assignment+0x61>
jmp    1256 <check_assignment+0x146>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    11ab <check_assignment+0x9b>
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    1243 <check_assignment+0x133>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jl     11ea <check_assignment+0xda>
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%ecx
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    123e <check_assignment+0x12e>
cmpl   $0x1,-0x18(%rbp)
jne    1239 <check_assignment+0x129>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x20(%rbp),%eax
jl     1239 <check_assignment+0x129>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    123e <check_assignment+0x12e>
jmp    1243 <check_assignment+0x133>
jmp    1248 <check_assignment+0x138>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <check_assignment+0x34>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_assignment>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r9d
shl    %cl,%r9d
xor    %eax,%eax
test   %esi,%esi
jle    11b3 <check_assignment+0x93>
mov    %edx,%ecx
mov    %rdi,%r14
mov    %esi,%esi
mov    $0x1,%ebx
jmp    115c <check_assignment+0x3c>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%rdx
cmp    %rsi,%rbx
mov    %rdx,%rbx
jae    11b3 <check_assignment+0x93>
mov    (%r14,%rbx,4),%edx
test   %edx,%edx
js     118c <check_assignment+0x6c>
cmp    %ecx,%edx
jge    119e <check_assignment+0x7e>
cmp    $0x1,%r8d
jne    1150 <check_assignment+0x30>
cmp    %r9d,%edx
jl     1150 <check_assignment+0x30>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14,%rbx,4),%edx
lea    0xec8(%rip),%rdi
jmp    1193 <check_assignment+0x73>
lea    0xe6d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ae <check_assignment+0x8e>
lea    0xe80(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Assignment[%d] = %d less than zero.\0A\00"
@.str.1 = [45 x i8] c"Assignment[%d] = %d, too large for %d sets.\0A\00"
@.str.2 = [66 x i8] c"Can only use local method on single level of read-in assignment,\0A\00"
@.str.3 = [29 x i8] c" but assignment[%d] = %d.\0A\00"
define i32 @check_assignment(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i32, i32* %9
%15 = shl i32 1, %14
store i32 %15, i32* %12
store i32 0, i32* %11
store i32 1, i32* %13
br label %16
16: ; preds = %81, %5
%17 = load i32, i32* %13
%18 = load i32, i32* %7
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %11
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br label %24
24: ; preds = %20, %16
%25 = phi i1 [ false, %16 ], [ %23, %20 ]
br i1 %25, label %26, label %84
26: ; preds = %24
%27 = load i32*, i32** %6
%28 = load i32, i32* %13
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %26
%34 = load i32, i32* %13
%35 = load i32*, i32** %6
%36 = load i32, i32* %13
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %34, i32 %39)
store i32 1, i32* %11
br label %80
41: ; preds = %26
%42 = load i32*, i32** %6
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %8
%48 = icmp sge i32 %46, %47
br i1 %48, label %49, label %58
49: ; preds = %41
%50 = load i32, i32* %13
%51 = load i32*, i32** %6
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = load i32, i32* %8
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %50, i32 %55, i32 %56)
store i32 1, i32* %11
br label %79
58: ; preds = %41
%59 = load i32, i32* %10
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %78
61: ; preds = %58
%62 = load i32*, i32** %6
%63 = load i32, i32* %13
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %62, i64 %64
%66 = load i32, i32* %65
%67 = load i32, i32* %12
%68 = icmp sge i32 %66, %67
br i1 %68, label %69, label %78
69: ; preds = %61
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0))
%71 = load i32, i32* %13
%72 = load i32*, i32** %6
%73 = load i32, i32* %13
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %71, i32 %76)
store i32 1, i32* %11
br label %78
78: ; preds = %69, %61, %58
br label %79
79: ; preds = %78, %49
br label %80
80: ; preds = %79, %33
br label %81
81: ; preds = %80
%82 = load i32, i32* %13
%83 = add nsw i32 %82, 1
store i32 %83, i32* %13
br label %16
84: ; preds = %24
%85 = load i32, i32* %11
ret i32 %85
}

LLVM IR (-O2):
@.str = [37 x i8] c"Assignment[%d] = %d less than zero.\0A\00"
@.str.1 = [45 x i8] c"Assignment[%d] = %d, too large for %d sets.\0A\00"
@.str.3 = [29 x i8] c" but assignment[%d] = %d.\0A\00"
@str = [65 x i8] c"Can only use local method on single level of read-in assignment,\00"
define i32 @check_assignment(i32* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = shl nuw i32 1, %3
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %36
8: ; preds = %5
%9 = icmp ne i32 %4, 1
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %8, %33
%12 = phi i64 [ 1, %8 ], [ %34, %33 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = trunc i64 %12 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %14)
br label %36
19: ; preds = %11
%20 = icmp slt i32 %14, %2
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = trunc i64 %12 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %14, i32 %2)
br label %36
24: ; preds = %19
%25 = icmp slt i32 %14, %6
%26 = select i1 %9, i1 true, i1 %25
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = getelementptr inbounds i32, i32* %0, i64 %12
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%30 = load i32, i32* %28
%31 = trunc i64 %12 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %30)
br label %36
33: ; preds = %24
%34 = add nuw nsw i64 %12, 1
%35 = icmp ult i64 %12, %10
br i1 %35, label %11, label %36
36: ; preds = %33, %21, %27, %16, %5
%37 = phi i32 [ 0, %5 ], [ 1, %16 ], [ 1, %27 ], [ 1, %21 ], [ 0, %33 ]
ret i32 %37
}