#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 test_modulo(void) {
  static int e = 0;
  volatile int a;
  volatile int b;
  a = -5;
  b = 2;
  if (a % b != -1) {
    printf("m1 ");
    e++;
  }
  a = -5;
  b = -2;
  if (a % b != -1) {
    printf("m2 ");
    e++;
  }
  a = 5;
  b = -2;
  if (a % b != 1) {
    printf("m3 ");
    e++;
  }
  if (e) {
    printf("\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_modulo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xfffffffb,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0xffffffff,%edx
je     1153 <test_modulo+0x43>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ee2(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed9(%rip)
movl   $0xfffffffb,-0x8(%rbp)
movl   $0xfffffffe,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0xffffffff,%edx
je     118e <test_modulo+0x7e>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ea7(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e9e(%rip)
movl   $0x5,-0x8(%rbp)
movl   $0xfffffffe,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
je     11c9 <test_modulo+0xb9>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e6c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e63(%rip)
cmpl   $0x0,0x2e5c(%rip)
je     11ee <test_modulo+0xde>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f5 <test_modulo+0xe5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_modulo>:
push   %rax
movl   $0xfffffffb,0x4(%rsp)
ff
movl   $0x2,(%rsp)
mov    0x4(%rsp),%eax
cltd
idivl  (%rsp)
cmp    $0xffffffff,%edx
je     1150 <test_modulo+0x30>
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
addl   $0x1,0x2ee4(%rip)
movl   $0xfffffffb,0x4(%rsp)
ff
movl   $0xfffffffe,(%rsp)
mov    0x4(%rsp),%eax
cltd
idivl  (%rsp)
cmp    $0xffffffff,%edx
je     117f <test_modulo+0x5f>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
addl   $0x1,0x2eb5(%rip)
movl   $0x5,0x4(%rsp)
movl   $0xfffffffe,(%rsp)
mov    0x4(%rsp),%eax
cltd
idivl  (%rsp)
cmp    $0x1,%edx
jne    11b6 <test_modulo+0x96>
mov    0x2e93(%rip),%eax
test   %eax,%eax
je     11d5 <test_modulo+0xb5>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e6c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e63(%rip)
test   %eax,%eax
jne    11a5 <test_modulo+0x85>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@test_modulo.e = internal global i32 0
@.str = [4 x i8] c"m1 \00"
@.str.1 = [4 x i8] c"m2 \00"
@.str.2 = [4 x i8] c"m3 \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @test_modulo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store volatile i32 -5, i32* %2
store volatile i32 2, i32* %3
%4 = load volatile i32, i32* %2
%5 = load volatile i32, i32* %3
%6 = srem i32 %4, %5
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @test_modulo.e
%11 = add nsw i32 %10, 1
store i32 %11, i32* @test_modulo.e
br label %12
12: ; preds = %8, %0
store volatile i32 -5, i32* %2
store volatile i32 -2, i32* %3
%13 = load volatile i32, i32* %2
%14 = load volatile i32, i32* %3
%15 = srem i32 %13, %14
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @test_modulo.e
%20 = add nsw i32 %19, 1
store i32 %20, i32* @test_modulo.e
br label %21
21: ; preds = %17, %12
store volatile i32 5, i32* %2
store volatile i32 -2, i32* %3
%22 = load volatile i32, i32* %2
%23 = load volatile i32, i32* %3
%24 = srem i32 %22, %23
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* @test_modulo.e
%29 = add nsw i32 %28, 1
store i32 %29, i32* @test_modulo.e
br label %30
30: ; preds = %26, %21
%31 = load i32, i32* @test_modulo.e
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %36
35: ; preds = %30
store i32 0, i32* %1
br label %36
36: ; preds = %35, %33
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@test_modulo.e = internal unnamed_addr global i32 0
@.str = [4 x i8] c"m1 \00"
@.str.1 = [4 x i8] c"m2 \00"
@.str.2 = [4 x i8] c"m3 \00"
define i32 @test_modulo() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store volatile i32 -5, i32* %1
store volatile i32 2, i32* %2
%5 = load volatile i32, i32* %1
%6 = load volatile i32, i32* %2
%7 = srem i32 %5, %6
%8 = icmp eq i32 %7, -1
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @test_modulo.e
%12 = add nsw i32 %11, 1
store i32 %12, i32* @test_modulo.e
br label %13
13: ; preds = %9, %0
store volatile i32 -5, i32* %1
store volatile i32 -2, i32* %2
%14 = load volatile i32, i32* %1
%15 = load volatile i32, i32* %2
%16 = srem i32 %14, %15
%17 = icmp eq i32 %16, -1
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @test_modulo.e
%21 = add nsw i32 %20, 1
store i32 %21, i32* @test_modulo.e
br label %22
22: ; preds = %18, %13
store volatile i32 5, i32* %1
store volatile i32 -2, i32* %2
%23 = load volatile i32, i32* %1
%24 = load volatile i32, i32* %2
%25 = srem i32 %23, %24
%26 = icmp eq i32 %25, 1
br i1 %26, label %31, label %27
27: ; preds = %22
%28 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* @test_modulo.e
%30 = add nsw i32 %29, 1
store i32 %30, i32* @test_modulo.e
br label %33
31: ; preds = %22
%32 = load i32, i32* @test_modulo.e
br label %33
33: ; preds = %31, %27
%34 = phi i32 [ %32, %31 ], [ %30, %27 ]
%35 = icmp eq i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = tail call i32 @putchar(i32 10)
br label %38
38: ; preds = %33, %36
%39 = phi i32 [ 1, %36 ], [ 0, %33 ]
ret i32 %39
}