#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*/ cmdline;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ Usage(char *);
int /*<<< orphan*/ dump(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *const);
int fputs(char *, int /*<<< orphan*/);
scalar_t__ isatty(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ talloc_enable_leak_report();
int /*<<< orphan*/ talloc_free(void *);
void *talloc_named_const(int /*<<< orphan*/ *, int /*<<< orphan*/, char *);
int main(int argc, char **argv) {
  talloc_enable_leak_report();
  if (argc > 2 || (argc == 2 && strcmp(argv[1], "-help") == 0)) {
    Usage(argv[0]);
  }
  printf("--> charset conversion code : %s\n", "DISABLED");
  const char *const charset = (argc > 1 ? argv[1] : NULL);
  int rc = 0;
  if (rc) {
    fprintf(stderr, "Error initialising charset %s\n",
            charset ? charset : "(default locale)");
    Usage(argv[0]);
  }
  int fatal = 0;
  while (!fatal) {
    char cmdline[BUFSIZ];
    if (isatty(fileno(stdin)))
      printf("\n>> ");
    if (fgets(cmdline, sizeof(cmdline), stdin) == NULL)
      break;
    if (*cmdline) {
      size_t cmdlen = strlen(cmdline);
      if (cmdline[cmdlen - 1] == '\n')
        cmdline[--cmdlen] = '\0';
      printf("len = %d\n", cmdlen);
      void *tmp_ctx = talloc_named_const(
          NULL, 0,
          "talloc_new: "
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/emwgit/djmount/refs/heads/master/djmount/"
          "test_charset.c"
          ":"
          "116");
      printf("\n1) ConvertString to UTF8 \n");
      char buffer1[40];
      char *result1 = ((char *)(cmdline));
      if (result1) {
        dump(result1);
        printf("len = %d\n", strlen(result1));
        if (result1 == buffer1)
          printf("allocated on stack\n");
        else
          printf("allocated by talloc\n");
      } else {
        printf(" ** NULL ! **\n");
        fatal++;
      }
      printf("\n2) PrintString UTF8 \n");
      rc = fputs(result1, stdout);
      if (rc < 0) {
        printf(" *** error printing string *** "
               "rc = %d\n",
               rc);
        fatal++;
      }
      printf("\n");
      printf("\n3) ConvertString back from UTF8 \n");
      char buffer2[40];
      char *result2 = ((char *)(result1));
      if (result2) {
        printf("str = '%s'\n", result2);
        dump(result2);
        printf("len = %d\n", strlen(result2));
        if (result2 == buffer2)
          printf("allocated on stack\n");
        else
          printf("allocated by talloc\n");
      } else {
        printf(" ** NULL ! **\n");
        fatal++;
      }
      printf("\n4) Compare strings \n");
      if (result2 && strcmp(cmdline, result2) == 0)
        printf(" ok\n");
      else {
        printf(" *** error, differ ! *** \n");
        fatal++;
      }
      talloc_free(tmp_ctx);
      tmp_ctx = NULL;
    }
  }
  0;
  exit(fatal);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1100 <talloc_enable_leak_report@plt>
cmpl   $0x2,-0x8(%rbp)
jg     1232 <main+0x52>
cmpl   $0x2,-0x8(%rbp)
jne    123e <main+0x5e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xddd(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    123e <main+0x5e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <Usage@plt>
lea    0xdc1(%rip),%rdi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1271 <main+0x91>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0xb0(%rbp)
jmp    127f <main+0x9f>
xor    %eax,%eax
mov    %rax,-0xb0(%rbp)
jmp    127f <main+0x9f>
mov    -0xb0(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12fd <main+0x11d>
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12c5 <main+0xe5>
mov    -0x18(%rbp),%rax
mov    %rax,-0xc0(%rbp)
jmp    12d8 <main+0xf8>
lea    0xd84(%rip),%rax
mov    %rax,-0xc0(%rbp)
jmp    12d8 <main+0xf8>
mov    -0xb4(%rbp),%edi
mov    -0xc0(%rbp),%rdx
lea    0xd45(%rip),%rsi
call   10d0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <Usage@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    131a <main+0x13a>
jmp    1672 <main+0x492>
mov    0x2caf(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xd0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xc8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
call   10e0 <fileno@plt>
mov    %eax,%edi
call   1040 <isatty@plt>
cmp    $0x0,%rax
je     137d <main+0x19d>
lea    0xceb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xd0(%rbp),%rax
mov    %eax,%esi
mov    0x2c54(%rip),%rax
mov    (%rax),%edx
call   10a0 <fgets@plt>
cmp    $0x0,%rax
jne    13b1 <main+0x1d1>
movl   $0x3,-0x34(%rbp)
jmp    1651 <main+0x471>
mov    -0xc8(%rbp),%rax
cmpb   $0x0,(%rax)
je     164a <main+0x46a>
mov    -0xc8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xc8(%rbp),%rax
movslq %ecx,%rcx
mov    %rcx,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    140d <main+0x22d>
mov    -0xc8(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %rcx,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x40(%rbp)
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x40(%rbp),%rsi
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xc44(%rip),%rdx
call   1050 <talloc_named_const@plt>
mov    %rax,-0x48(%rbp)
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc8(%rbp),%rax
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     14b2 <main+0x2d2>
mov    -0x78(%rbp),%rdi
call   1090 <dump@plt>
mov    -0x78(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%esi
lea    0xbf2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x78(%rbp),%rax
lea    -0x70(%rbp),%rcx
cmp    %rcx,%rax
jne    149f <main+0x2bf>
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14ad <main+0x2cd>
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14c9 <main+0x2e9>
lea    0xc9e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x78(%rbp),%rdi
mov    0x2ae6(%rip),%rax
mov    (%rax),%esi
call   1080 <fputs@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1510 <main+0x330>
mov    -0x1c(%rbp),%esi
lea    0xc7d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc80(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     15bf <main+0x3df>
mov    -0xa8(%rbp),%rsi
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   1090 <dump@plt>
mov    -0xa8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%esi
lea    0xaeb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xa8(%rbp),%rax
lea    -0xa0(%rbp),%rcx
cmp    %rcx,%rax
jne    15ac <main+0x3cc>
lea    0xb8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15ba <main+0x3da>
lea    0xb8f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15d6 <main+0x3f6>
lea    0xb91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    0xbf7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpq   $0x0,-0xa8(%rbp)
je     1622 <main+0x442>
mov    -0xc8(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1622 <main+0x442>
lea    0xbd4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1639 <main+0x459>
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <talloc_free@plt>
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x34(%rbp),%eax
test   %eax,%eax
je     166d <main+0x48d>
jmp    1668 <main+0x488>
jmp    1672 <main+0x492>
jmp    1304 <main+0x124>
mov    -0x20(%rbp),%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
xor    %eax,%eax
call   1110 <talloc_enable_leak_report@plt>
cmp    $0x2,%ebx
jg     1226 <main+0x36>
jne    122e <main+0x3e>
mov    0x8(%r14),%rdi
lea    0xde4(%rip),%rsi
call   10e0 <strcmp@plt>
test   %rax,%rax
jne    122e <main+0x3e>
mov    (%r14),%rdi
call   10d0 <Usage@plt>
lea    0xdd1(%rip),%rdi
lea    0xdec(%rip),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2d9e(%rip),%r14
lea    0xde5(%rip),%r12
jmp    1270 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r13d,%r13d
mov    -0x30(%rbp),%rsp
test   %r13d,%r13d
jne    1426 <main+0x236>
mov    %rsp,%r13
mov    0x2d5e(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r15
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    (%r14),%edi
call   10f0 <fileno@plt>
mov    %eax,%edi
call   1060 <isatty@plt>
test   %rax,%rax
je     12af <main+0xbf>
lea    0xd89(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    (%r14),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   10c0 <fgets@plt>
test   %rax,%rax
je     1420 <main+0x230>
cmpb   $0x0,(%r15)
mov    %r13,-0x30(%rbp)
je     1260 <main+0x70>
mov    %r15,%rdi
call   1080 <strlen@plt>
movslq %eax,%rsi
cmpb   $0xa,-0x1(%r15,%rsi,1)
jne    12eb <main+0xfb>
add    $0xffffffffffffffff,%rsi
movb   $0x0,(%r15,%rsi,1)
xor    %r13d,%r13d
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %edi,%edi
xor    %esi,%esi
lea    0xd3d(%rip),%rdx
call   1070 <talloc_named_const@plt>
mov    %rax,%r14
lea    0xe04(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   10b0 <dump@plt>
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe2f(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xde8(%rip),%rdi
call   1050 <puts@plt>
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10a0 <fputs@plt>
test   %eax,%eax
jns    1379 <main+0x189>
lea    0xd78(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%r13d
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdbd(%rip),%rdi
call   1050 <puts@plt>
lea    0xd74(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   10b0 <dump@plt>
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xdb2(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
mov    %r15,%rsi
call   10e0 <strcmp@plt>
test   %rax,%rax
je     1400 <main+0x210>
lea    0xdab(%rip),%rdi
call   1050 <puts@plt>
add    $0x1,%r13d
jmp    140c <main+0x21c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xda5(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1040 <talloc_free@plt>
mov    0x2bcd(%rip),%r14
jmp    1263 <main+0x73>
mov    %r13,%rsp
xor    %r13d,%r13d
mov    %r13d,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"-help\00"
@.str.1 = [34 x i8] c"--> charset conversion code : %s\0A\00"
@.str.2 = [9 x i8] c"DISABLED\00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"Error initialising charset %s\0A\00"
@.str.4 = [17 x i8] c"(default locale)\00"
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str.5 = [5 x i8] c"\0A>> \00"
@.str.6 = [10 x i8] c"len = %d\0A\00"
@.str.7 = [162 x i8] c"talloc_new: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/emwgit/djmount/refs/heads/master/djmount/test_charset.c:116\00"
@.str.8 = [28 x i8] c"\0A1) ConvertString to UTF8 \0A\00"
@.str.9 = [20 x i8] c"allocated on stack\0A\00"
@.str.10 = [21 x i8] c"allocated by talloc\0A\00"
@.str.11 = [15 x i8] c" ** NULL ! **\0A\00"
@.str.12 = [23 x i8] c"\0A2) PrintString UTF8 \0A\00"
@stdout = global i32 0
@.str.13 = [40 x i8] c" *** error printing string *** rc = %d\0A\00"
@.str.14 = [2 x i8] c"\0A\00"
@.str.15 = [35 x i8] c"\0A3) ConvertString back from UTF8 \0A\00"
@.str.16 = [12 x i8] c"str = '%s'\0A\00"
@.str.17 = [22 x i8] c"\0A4) Compare strings \0A\00"
@.str.18 = [5 x i8] c" ok\0A\00"
@.str.19 = [27 x i8] c" *** error, differ ! *** \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i64
%13 = alloca i8*
%14 = alloca [40 x i8]
%15 = alloca i8*
%16 = alloca [40 x i8]
%17 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = call i32 (...) @talloc_enable_leak_report()
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %30, label %21
21: ; preds = %2
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %35
24: ; preds = %21
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %24, %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @Usage(i8* %33)
br label %35
35: ; preds = %30, %24, %21
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %4
%38 = icmp sgt i32 %37, 1
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
br label %44
43: ; preds = %35
br label %44
44: ; preds = %43, %39
%45 = phi i8* [ %42, %39 ], [ null, %43 ]
store i8* %45, i8** %6
store i32 0, i32* %7
%46 = load i32, i32* %7
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %62
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %6
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = load i8*, i8** %6
br label %55
54: ; preds = %48
br label %55
55: ; preds = %54, %52
%56 = phi i8* [ %53, %52 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), %54 ]
%57 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 0
%60 = load i8*, i8** %59
%61 = call i32 @Usage(i8* %60)
br label %62
62: ; preds = %55, %44
store i32 0, i32* %8
br label %63
63: ; preds = %184, %62
%64 = load i32, i32* %8
%65 = icmp ne i32 %64, 0
%66 = xor i1 %65, true
br i1 %66, label %67, label %185
67: ; preds = %63
%68 = load i32, i32* @BUFSIZ
%69 = zext i32 %68 to i64
%70 = call i8* @llvm.stacksave()
store i8* %70, i8** %9
%71 = alloca i8, i64 %69
store i64 %69, i64* %10
%72 = load i32, i32* @stdin
%73 = call i32 @fileno(i32 %72)
%74 = call i64 @isatty(i32 %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %67
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %78
78: ; preds = %76, %67
%79 = trunc i64 %69 to i32
%80 = load i32, i32* @stdin
%81 = call i32* @fgets(i8* %71, i32 %79, i32 %80)
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %84
83: ; preds = %78
store i32 3, i32* %11
br label %181
84: ; preds = %78
%85 = load i8, i8* %71
%86 = icmp ne i8 %85, 0
br i1 %86, label %87, label %180
87: ; preds = %84
%88 = call i32 @strlen(i8* %71)
%89 = sext i32 %88 to i64
store i64 %89, i64* %12
%90 = load i64, i64* %12
%91 = sub i64 %90, 1
%92 = getelementptr inbounds i8, i8* %71, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 10
br i1 %95, label %96, label %100
96: ; preds = %87
%97 = load i64, i64* %12
%98 = add i64 %97, -1
store i64 %98, i64* %12
%99 = getelementptr inbounds i8, i8* %71, i64 %98
store i8 0, i8* %99
br label %100
100: ; preds = %96, %87
%101 = load i64, i64* %12
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %101)
%103 = call i8* @talloc_named_const(i32* null, i32 0, i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.7, i64 0, i64 0))
store i8* %103, i8** %13
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
store i8* %71, i8** %15
%105 = load i8*, i8** %15
%106 = icmp ne i8* %105, null
br i1 %106, label %107, label %121
107: ; preds = %100
%108 = load i8*, i8** %15
%109 = call i32 @dump(i8* %108)
%110 = load i8*, i8** %15
%111 = call i32 @strlen(i8* %110)
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %111)
%113 = load i8*, i8** %15
%114 = getelementptr inbounds [40 x i8], [40 x i8]* %14, i64 0, i64 0
%115 = icmp eq i8* %113, %114
br i1 %115, label %116, label %118
116: ; preds = %107
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %120
118: ; preds = %107
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %120
120: ; preds = %118, %116
br label %125
121: ; preds = %100
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%123 = load i32, i32* %8
%124 = add nsw i32 %123, 1
store i32 %124, i32* %8
br label %125
125: ; preds = %121, %120
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
%127 = load i8*, i8** %15
%128 = load i32, i32* @stdout
%129 = call i32 @fputs(i8* %127, i32 %128)
store i32 %129, i32* %7
%130 = load i32, i32* %7
%131 = icmp slt i32 %130, 0
br i1 %131, label %132, label %137
132: ; preds = %125
%133 = load i32, i32* %7
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i32 %133)
%135 = load i32, i32* %8
%136 = add nsw i32 %135, 1
store i32 %136, i32* %8
br label %137
137: ; preds = %132, %125
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0))
%140 = load i8*, i8** %15
store i8* %140, i8** %17
%141 = load i8*, i8** %17
%142 = icmp ne i8* %141, null
br i1 %142, label %143, label %159
143: ; preds = %137
%144 = load i8*, i8** %17
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8* %144)
%146 = load i8*, i8** %17
%147 = call i32 @dump(i8* %146)
%148 = load i8*, i8** %17
%149 = call i32 @strlen(i8* %148)
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %149)
%151 = load i8*, i8** %17
%152 = getelementptr inbounds [40 x i8], [40 x i8]* %16, i64 0, i64 0
%153 = icmp eq i8* %151, %152
br i1 %153, label %154, label %156
154: ; preds = %143
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %158
156: ; preds = %143
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %158
158: ; preds = %156, %154
br label %163
159: ; preds = %137
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%161 = load i32, i32* %8
%162 = add nsw i32 %161, 1
store i32 %162, i32* %8
br label %163
163: ; preds = %159, %158
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0))
%165 = load i8*, i8** %17
%166 = icmp ne i8* %165, null
br i1 %166, label %167, label %173
167: ; preds = %163
%168 = load i8*, i8** %17
%169 = call i64 @strcmp(i8* %71, i8* %168)
%170 = icmp eq i64 %169, 0
br i1 %170, label %171, label %173
171: ; preds = %167
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
br label %177
173: ; preds = %167, %163
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.19, i64 0, i64 0))
%175 = load i32, i32* %8
%176 = add nsw i32 %175, 1
store i32 %176, i32* %8
br label %177
177: ; preds = %173, %171
%178 = load i8*, i8** %13
%179 = call i32 @talloc_free(i8* %178)
store i8* null, i8** %13
br label %180
180: ; preds = %177, %84
store i32 0, i32* %11
br label %181
181: ; preds = %180, %83
%182 = load i8*, i8** %9
%183 = load i32, i32* %11
switch i32 %183, label %188 [
i32 0, label %184
i32 3, label %185
]
184: ; preds = %181
br label %63
185: ; preds = %181, %63
%186 = load i32, i32* %8
%187 = call i32 @exit(i32 %186)
unreachable
188: ; preds = %181
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"-help\00"
@.str.1 = [34 x i8] c"--> charset conversion code : %s\0A\00"
@.str.2 = [9 x i8] c"DISABLED\00"
@stderr = global i32 0
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str.5 = [5 x i8] c"\0A>> \00"
@.str.6 = [10 x i8] c"len = %d\0A\00"
@.str.7 = [162 x i8] c"talloc_new: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/emwgit/djmount/refs/heads/master/djmount/test_charset.c:116\00"
@stdout = global i32 0
@.str.13 = [40 x i8] c" *** error printing string *** rc = %d\0A\00"
@.str.16 = [12 x i8] c"str = '%s'\0A\00"
@str = [27 x i8] c"\0A1) ConvertString to UTF8 \00"
@str.21 = [22 x i8] c"\0A2) PrintString UTF8 \00"
@str.22 = [34 x i8] c"\0A3) ConvertString back from UTF8 \00"
@str.23 = [20 x i8] c"allocated by talloc\00"
@str.24 = [21 x i8] c"\0A4) Compare strings \00"
@str.25 = [26 x i8] c" *** error, differ ! *** \00"
@str.26 = [4 x i8] c" ok\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @talloc_enable_leak_report()
%4 = icmp sgt i32 %0, 2
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = icmp eq i32 %0, 2
br i1 %6, label %7, label %15
7: ; preds = %5
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7, %2
%13 = load i8*, i8** %1
%14 = tail call i32 @Usage(i8* %13)
br label %15
15: ; preds = %12, %7, %5
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %79
%18 = load i32, i32* @BUFSIZ
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
%21 = alloca i8, i64 %19
%22 = load i32, i32* @stdin
%23 = call i32 @fileno(i32 %22)
%24 = call i64 @isatty(i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %28
28: ; preds = %26, %17
%29 = load i32, i32* @stdin
%30 = call i32* @fgets(i8* %21, i32 %18, i32 %29)
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %33
32: ; preds = %28
br label %82
33: ; preds = %28
%34 = load i8, i8* %21
%35 = icmp eq i8 %34, 0
br i1 %35, label %79, label %36
36: ; preds = %33
%37 = call i32 @strlen(i8* %21)
%38 = sext i32 %37 to i64
%39 = add nsw i64 %38, -1
%40 = getelementptr inbounds i8, i8* %21, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 10
br i1 %42, label %43, label %44
43: ; preds = %36
store i8 0, i8* %40
br label %44
44: ; preds = %43, %36
%45 = phi i64 [ %39, %43 ], [ %38, %36 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %45)
%47 = call i8* @talloc_named_const(i32* null, i32 0, i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.7, i64 0, i64 0))
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%49 = call i32 @dump(i8* %21)
%50 = call i32 @strlen(i8* %21)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %50)
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.23, i64 0, i64 0))
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.21, i64 0, i64 0))
%54 = load i32, i32* @stdout
%55 = call i32 @fputs(i8* %21, i32 %54)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %44
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i32 %55)
br label %59
59: ; preds = %57, %44
%60 = phi i32 [ 1, %57 ], [ 0, %44 ]
%61 = call i32 @putchar(i32 10)
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.22, i64 0, i64 0))
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8* %21)
%64 = call i32 @dump(i8* %21)
%65 = call i32 @strlen(i8* %21)
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %65)
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.23, i64 0, i64 0))
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.24, i64 0, i64 0))
%69 = call i64 @strcmp(i8* %21, i8* %21)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %59
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.26, i64 0, i64 0))
br label %76
73: ; preds = %59
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.25, i64 0, i64 0))
%75 = add nuw nsw i32 %60, 1
br label %76
76: ; preds = %73, %71
%77 = phi i32 [ %60, %71 ], [ %75, %73 ]
%78 = call i32 @talloc_free(i8* %47)
br label %79
79: ; preds = %33, %76
%80 = phi i32 [ %77, %76 ], [ 0, %33 ]
%81 = icmp eq i32 %80, 0
br i1 %81, label %17, label %82
82: ; preds = %79, %32
%83 = phi i32 [ 0, %32 ], [ %80, %79 ]
%84 = call i32 @exit(i32 %83)
unreachable
}