#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*/ bdes_err(int, char *);
int strtoul(char *, char **, int);
int setbits(char *s, int mult) {
  char *p;
  int n;
  n = strtoul(s, &p, 10);
  if (*p != 0)
    bdes_err(-1, "bad decimal digit in MAC length");
  return ((n % mult != 0) ? -1 : n);
}


x86 assembly (clang, -O0):
<setbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1165 <setbits+0x45>
mov    $0xffffffff,%edi
lea    0xea0(%rip),%rsi
call   1030 <bdes_err@plt>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
je     1182 <setbits+0x62>
mov    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1188 <setbits+0x68>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setbits>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     114e <setbits+0x2e>
lea    0xebc(%rip),%rsi
mov    $0xffffffff,%edi
call   1030 <bdes_err@plt>
mov    %ebp,%eax
cltd
idiv   %ebx
neg    %edx
sbb    %eax,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"bad decimal digit in MAC length\00"
define i32 @setbits(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strtoul(i8* %7, i8** %5, i32 10)
store i32 %8, i32* %6
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @bdes_err(i32 -1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = srem i32 %16, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %23
21: ; preds = %15
%22 = load i32, i32* %6
br label %23
23: ; preds = %21, %20
%24 = phi i32 [ -1, %20 ], [ %22, %21 ]
ret i32 %24
}

LLVM IR (-O2):
@.str = [32 x i8] c"bad decimal digit in MAC length\00"
define i32 @setbits(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @strtoul(i8* %0, i8** %3, i32 10)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 @bdes_err(i32 -1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = srem i32 %5, %1
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i32 %5, i32 -1
ret i32 %14
}