#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, int, int, char *, char *);
int sscanf(char *, char *, char *, ...);
char *strchr(char *, char);
int strlen(char *);
void liste(void) {
  FILE *fp;
  char nom[100];
  char nom2[200];
  char reste[200];
  char buf[500], *b;
  int n, s1, s2;
  if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
    return;
  while (fgets(buf, 500, fp) != NULL) {
    n = strlen(buf);
    buf[n - 1] = '\0';
    s1 = sscanf(buf, "%s %s :", nom, nom2);
    b = strchr(buf, ':');
    if (b == NULL)
      continue;
    s2 = sscanf(b + 1, " %s", reste);
    printf("Lu : <%s> s1=%d s2=%d nom=%s reste=%s\n", buf, s1, s2, nom, b + 1);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<liste>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
lea    0xe7e(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    11a1 <liste+0x31>
jmp    129d <liste+0x12d>
jmp    11a6 <liste+0x36>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1f4,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1294 <liste+0x124>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x41c(%rbp)
mov    -0x41c(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
mov    %eax,-0x420(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    123b <liste+0xcb>
jmp    11a6 <liste+0x36>
mov    -0x418(%rbp),%rdi
add    $0x1,%rdi
lea    -0x210(%rbp),%rdx
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
mov    %eax,-0x424(%rbp)
lea    -0x410(%rbp),%rsi
mov    -0x420(%rbp),%edx
mov    -0x424(%rbp),%ecx
lea    -0x70(%rbp),%r8
mov    -0x418(%rbp),%r9
add    $0x1,%r9
lea    0xd92(%rip),%rdi
call   1060 <printf@plt>
jmp    11a6 <liste+0x36>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<liste>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xe78(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1262 <liste+0xf2>
mov    %rax,%r14
lea    0x210(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1f4,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     125a <liste+0xea>
mov    %rsp,%r12
lea    0x140(%rsp),%r13
jmp    11e5 <liste+0x75>
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x1f4,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     125a <liste+0xea>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
lea    0xe12(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1080 <sscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d0 <liste+0x60>
mov    %rax,%r15
add    $0x1,%r15
mov    %r15,%rdi
lea    0xde8(%rip),%rsi
lea    0x70(%rsp),%rdx
xor    %eax,%eax
call   1080 <sscanf@plt>
lea    0xdd9(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
mov    %r12,%r8
mov    %r15,%r9
call   1060 <printf@plt>
jmp    11d0 <liste+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"%s %s :\00"
@.str.3 = [4 x i8] c" %s\00"
@.str.4 = [39 x i8] c"Lu : <%s> s1=%d s2=%d nom=%s reste=%s\0A\00"
define void @liste() {
%1 = alloca i32*
%2 = alloca [100 x i8]
%3 = alloca [200 x i8]
%4 = alloca [200 x i8]
%5 = alloca [500 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %1
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %0
br label %50
13: ; preds = %0
br label %14
14: ; preds = %35, %34, %13
%15 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%16 = load i32*, i32** %1
%17 = call i32* @fgets(i8* %15, i32 500, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %47
19: ; preds = %14
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%29 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %28)
store i32 %29, i32* %8
%30 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%31 = call i8* @strchr(i8* %30, i8 signext 58)
store i8* %31, i8** %6
%32 = load i8*, i8** %6
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %19
br label %14
35: ; preds = %19
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%39 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %38)
store i32 %39, i32* %9
%40 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %40, i32 %41, i32 %42, i8* %43, i8* %45)
br label %14
47: ; preds = %14
%48 = load i32*, i32** %1
%49 = call i32 @fclose(i32* %48)
br label %50
50: ; preds = %47, %12
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"%s %s :\00"
@.str.3 = [4 x i8] c" %s\00"
@.str.4 = [39 x i8] c"Lu : <%s> s1=%d s2=%d nom=%s reste=%s\0A\00"
define void @liste() {
%1 = alloca [100 x i8]
%2 = alloca [200 x i8]
%3 = alloca [200 x i8]
%4 = alloca [500 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %31, label %11
11: ; preds = %0
%12 = call i32* @fgets(i8* %8, i32 500, i32* %9)
%13 = icmp eq i32* %12, null
br i1 %13, label %29, label %14
14: ; preds = %11, %26
%15 = call i32 @strlen(i8* %8)
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %6)
%20 = call i8* @strchr(i8* %8, i8 signext 58)
%21 = icmp eq i8* %20, null
br i1 %21, label %26, label %22
22: ; preds = %14
%23 = getelementptr inbounds i8, i8* %20, i64 1
%24 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%25 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %8, i32 %19, i32 %24, i8* %5, i8* %23)
br label %26
26: ; preds = %22, %14
%27 = call i32* @fgets(i8* %8, i32 500, i32* %9)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %14
29: ; preds = %26, %11
%30 = call i32 @fclose(i32* %9)
br label %31
31: ; preds = %0, %29
ret void
}