#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 IPC_CREAT;
int msgget(int, int);
int /*<<< orphan*/ printf(char *, int);
main() {
  int key;
  int msgQid;
  for (key = 0; key < 50; key++) {
    if (key % 2 == 0)
      msgQid = msgget(key, IPC_CREAT | 0644);
    printf("msgQid=%d\n", msgQid);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    118b <main+0x6b>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116e <main+0x4e>
mov    -0x8(%rbp),%edi
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
or     $0x1a4,%esi
call   1030 <msgget@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebx,%ebx
mov    0x2eaf(%rip),%r15
mov    $0x1a4,%r12d
lea    0xec2(%rip),%r14
jmp    1152 <main+0x32>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x32,%ebx
je     1168 <main+0x48>
test   $0x1,%bl
jne    1140 <main+0x20>
mov    (%r15),%esi
or     %r12d,%esi
mov    %ebx,%edi
call   1030 <msgget@plt>
mov    %eax,%ebp
jmp    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@.str = [11 x i8] c"msgQid=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %19, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 50
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = load i32, i32* %2
%9 = srem i32 %8, 2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* @IPC_CREAT
%14 = or i32 %13, 420
%15 = call i32 @msgget(i32 %12, i32 %14)
store i32 %15, i32* %3
br label %16
16: ; preds = %11, %7
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %4
22: ; preds = %4
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@IPC_CREAT = global i32 0
@.str = [11 x i8] c"msgQid=%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %10
%2 = phi i32 [ undef, %0 ], [ %11, %10 ]
%3 = phi i32 [ 0, %0 ], [ %13, %10 ]
%4 = and i32 %3, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @IPC_CREAT
%8 = or i32 %7, 420
%9 = tail call i32 @msgget(i32 %3, i32 %8)
br label %10
10: ; preds = %6, %1
%11 = phi i32 [ %9, %6 ], [ %2, %1 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 50
br i1 %14, label %15, label %1
15: ; preds = %10
ret i32 0
}