#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);
int /*<<< orphan*/ set_formats(int, int);
scalar_t__ strlen(char const *);
scalar_t__ strtol(char const *, char **, int);
void set_sigdigs(const char *optarg) {
  char *ptr1 = 0;
  char *ptr2 = 0;
  int flt_digits = 7;
  int dbl_digits = 15;
  if (optarg != 0 && (int)strlen(optarg) > 0 && optarg[0] != ',')
    flt_digits = (int)strtol(optarg, &ptr1, 10);
  if (flt_digits < 1 || flt_digits > 20) {
    error("unreasonable value for float significant digits: %d", flt_digits);
  }
  if (*ptr1 == ',')
    dbl_digits = (int)strtol(ptr1 + 1, &ptr2, 10);
  if (ptr2 == ptr1 + 1 || dbl_digits < 1 || dbl_digits > 20) {
    error("unreasonable value for double significant digits: %d", dbl_digits);
  }
  set_formats(flt_digits, dbl_digits);
}


x86 assembly (clang, -O0):
<set_sigdigs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x7,-0x1c(%rbp)
movl   $0xf,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ac <set_sigdigs+0x6c>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jle    11ac <set_sigdigs+0x6c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     11ac <set_sigdigs+0x6c>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jl     11c0 <set_sigdigs+0x80>
cmpl   $0x14,-0x1c(%rbp)
jle    11cf <set_sigdigs+0x8f>
mov    -0x1c(%rbp),%esi
lea    0xe36(%rip),%rdi
call   1060 <error@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    11f8 <set_sigdigs+0xb8>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
je     1221 <set_sigdigs+0xe1>
cmpl   $0x1,-0x20(%rbp)
jl     1221 <set_sigdigs+0xe1>
cmpl   $0x14,-0x20(%rbp)
jle    1230 <set_sigdigs+0xf0>
mov    -0x20(%rbp),%esi
lea    0xe09(%rip),%rdi
call   1060 <error@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <set_formats@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_sigdigs>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    $0x7,%r14d
test   %rdi,%rdi
je     11a2 <set_sigdigs+0x62>
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a2 <set_sigdigs+0x62>
cmpb   $0x2c,(%rbx)
je     11a2 <set_sigdigs+0x62>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%r14
add    $0xffffffeb,%eax
cmp    $0xffffffeb,%eax
ja     11a2 <set_sigdigs+0x62>
lea    0xe66(%rip),%rdi
mov    %r14d,%esi
call   1060 <error@plt>
mov    0x8(%rsp),%rbx
cmpb   $0x2c,(%rbx)
jne    11c6 <set_sigdigs+0x86>
lea    0x1(%rbx),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%r15
mov    (%rsp),%rax
jmp    11ce <set_sigdigs+0x8e>
mov    $0xf,%r15d
xor    %eax,%eax
add    $0x1,%rbx
cmp    %rbx,%rax
je     11e2 <set_sigdigs+0xa2>
test   %r15d,%r15d
jle    11e2 <set_sigdigs+0xa2>
cmp    $0x15,%r15d
jl     11f1 <set_sigdigs+0xb1>
lea    0xe4b(%rip),%rdi
mov    %r15d,%esi
call   1060 <error@plt>
mov    %r14d,%edi
mov    %r15d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <set_formats@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"unreasonable value for float significant digits: %d\00"
@.str.1 = [53 x i8] c"unreasonable value for double significant digits: %d\00"
define void @set_sigdigs(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i32 7, i32* %5
store i32 15, i32* %6
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %24
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i64 @strlen(i8* %10)
%12 = trunc i64 %11 to i32
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 44
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i8*, i8** %2
%22 = call i64 @strtol(i8* %21, i8** %3, i32 10)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %5
br label %24
24: ; preds = %20, %14, %9, %1
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %5
%29 = icmp sgt i32 %28, 20
br i1 %29, label %30, label %33
30: ; preds = %27, %24
%31 = load i32, i32* %5
%32 = call i32 @error(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %27
%34 = load i8*, i8** %3
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 44
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = call i64 @strtol(i8* %40, i8** %4, i32 10)
%42 = trunc i64 %41 to i32
store i32 %42, i32* %6
br label %43
43: ; preds = %38, %33
%44 = load i8*, i8** %4
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = icmp eq i8* %44, %46
br i1 %47, label %54, label %48
48: ; preds = %43
%49 = load i32, i32* %6
%50 = icmp slt i32 %49, 1
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i32, i32* %6
%53 = icmp sgt i32 %52, 20
br i1 %53, label %54, label %57
54: ; preds = %51, %48, %43
%55 = load i32, i32* %6
%56 = call i32 @error(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %54, %51
%58 = load i32, i32* %5
%59 = load i32, i32* %6
%60 = call i32 @set_formats(i32 %58, i32 %59)
ret void
}

LLVM IR (-O2):
@.str = [52 x i8] c"unreasonable value for float significant digits: %d\00"
@.str.1 = [53 x i8] c"unreasonable value for double significant digits: %d\00"
define void @set_sigdigs(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = icmp eq i8* %0, null
br i1 %6, label %21, label %7
7: ; preds = %1
%8 = tail call i64 @strlen(i8* %0)
%9 = trunc i64 %8 to i32
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 44
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%16 = trunc i64 %15 to i32
%17 = add i32 %16, -21
%18 = icmp ult i32 %17, -20
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @error(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %21
21: ; preds = %1, %7, %11, %14, %19
%22 = phi i32 [ %16, %14 ], [ %16, %19 ], [ 7, %11 ], [ 7, %7 ], [ 7, %1 ]
%23 = load i8*, i8** %2
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 44
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = getelementptr inbounds i8, i8* %23, i64 1
%28 = call i64 @strtol(i8* %27, i8** %3, i32 10)
%29 = trunc i64 %28 to i32
%30 = load i8*, i8** %3
br label %31
31: ; preds = %26, %21
%32 = phi i8* [ %30, %26 ], [ null, %21 ]
%33 = phi i32 [ %29, %26 ], [ 15, %21 ]
%34 = getelementptr inbounds i8, i8* %23, i64 1
%35 = icmp eq i8* %32, %34
%36 = icmp slt i32 %33, 1
%37 = select i1 %35, i1 true, i1 %36
%38 = icmp sgt i32 %33, 20
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %40, label %42
40: ; preds = %31
%41 = tail call i32 @error(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %42
42: ; preds = %31, %40
%43 = tail call i32 @set_formats(i32 %22, i32 %33)
ret void
}