#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 atoi(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int get_dconst(char *str, char *delim) {
  int val;
  char subs[80];
  if (delim - str < 1)
    return (-3);
  strncpy(subs, str, delim - str);
  subs[delim - str] = '\0';
  val = atoi(subs);
  if (val > 65535)
    puts("Warning: Decimal constant > 65535");
  return val;
}


x86 assembly (clang, -O0):
<get_dconst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x1,%rax
jge    1161 <get_dconst+0x31>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11b6 <get_dconst+0x86>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffff,-0x1c(%rbp)
jle    11b0 <get_dconst+0x80>
lea    0xe55(%rip),%rdi
call   1040 <puts@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dconst>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
sub    %rdi,%rbx
test   %rbx,%rbx
jle    1175 <get_dconst+0x45>
mov    %rdi,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%rsp,%rbx,1)
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
cmp    $0x10000,%eax
jl     117a <get_dconst+0x4a>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
jmp    117a <get_dconst+0x4a>
mov    $0xfffffffd,%ebx
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Warning: Decimal constant > 65535\00"
define i32 @get_dconst(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [80 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = load i8*, i8** %4
%10 = ptrtoint i8* %8 to i64
%11 = ptrtoint i8* %9 to i64
%12 = sub i64 %10, %11
%13 = icmp slt i64 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -3, i32* %3
br label %39
15: ; preds = %2
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = load i8*, i8** %4
%20 = ptrtoint i8* %18 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = trunc i64 %22 to i32
%24 = call i32 @strncpy(i8* %16, i8* %17, i32 %23)
%25 = load i8*, i8** %5
%26 = load i8*, i8** %4
%27 = ptrtoint i8* %25 to i64
%28 = ptrtoint i8* %26 to i64
%29 = sub i64 %27, %28
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp sgt i32 %33, 65535
br i1 %34, label %35, label %37
35: ; preds = %15
%36 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %35, %15
%38 = load i32, i32* %6
store i32 %38, i32* %3
br label %39
39: ; preds = %37, %14
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [34 x i8] c"Warning: Decimal constant > 65535\00"
define i32 @get_dconst(i8* %0, i8* %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = ptrtoint i8* %1 to i64
%6 = ptrtoint i8* %0 to i64
%7 = sub i64 %5, %6
%8 = icmp slt i64 %7, 1
br i1 %8, label %17, label %9
9: ; preds = %2
%10 = trunc i64 %7 to i32
%11 = call i32 @strncpy(i8* %4, i8* %0, i32 %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %7
store i8 0, i8* %12
%13 = call i32 @atoi(i8* %4)
%14 = icmp sgt i32 %13, 65535
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %9, %15, %2
%18 = phi i32 [ -3, %2 ], [ %13, %15 ], [ %13, %9 ]
ret i32 %18
}