#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*/ error(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ optarg;
int sscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ umask(int);
void set_umask() {
  int mask, result;
  result = sscanf(optarg, "%o", &mask);
  if ((result != 1) || (mask > 07777) || (mask < 0)) {
    error("bad umask value");
    exit(1);
  }
  umask(mask);
}


x86 assembly (clang, -O0):
<set_umask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1040 <sscanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1185 <set_umask+0x45>
cmpl   $0xfff,-0x4(%rbp)
jg     1185 <set_umask+0x45>
cmpl   $0x0,-0x4(%rbp)
jge    119b <set_umask+0x5b>
lea    0xe77(%rip),%rdi
call   1050 <error@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%edi
call   1030 <umask@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_umask>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    1177 <set_umask+0x37>
mov    0x4(%rsp),%edi
cmp    $0xfff,%edi
jg     1177 <set_umask+0x37>
test   %edi,%edi
js     1177 <set_umask+0x37>
call   1030 <umask@plt>
pop    %rax
ret
lea    0xe85(%rip),%rdi
call   1050 <error@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@optarg = global i32 0
@.str = [3 x i8] c"%o\00"
@.str.1 = [16 x i8] c"bad umask value\00"
define void @set_umask() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @optarg
%4 = call i32 @sscanf(i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 1
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 4095
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10, %7, %0
%14 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %10
%17 = load i32, i32* %1
%18 = call i32 @umask(i32 %17)
ret void
}

LLVM IR (-O2):
@optarg = global i32 0
@.str = [3 x i8] c"%o\00"
@.str.1 = [16 x i8] c"bad umask value\00"
define void @set_umask() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @optarg
%4 = call i32 @sscanf(i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = icmp ne i32 %4, 1
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 4095
%8 = select i1 %5, i1 true, i1 %7
%9 = icmp slt i32 %6, 0
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = call i32 @umask(i32 %6)
ret void
}